refactor(store): remove synthetic system bot user lookup (#5778)
Co-authored-by: memoclaw <265580040+memoclaw@users.noreply.github.com>
This commit is contained in:
parent
4f6730a12e
commit
4818bf3559
2 changed files with 0 additions and 25 deletions
|
|
@ -91,14 +91,6 @@ func TestUserGetByID(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Nil(t, notFound)
|
require.Nil(t, notFound)
|
||||||
|
|
||||||
// Get system bot
|
|
||||||
systemBotID := store.SystemBotID
|
|
||||||
systemBot, err := ts.GetUser(ctx, &store.FindUser{ID: &systemBotID})
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotNil(t, systemBot)
|
|
||||||
require.Equal(t, store.SystemBotID, systemBot.ID)
|
|
||||||
require.Equal(t, "system_bot", systemBot.Username)
|
|
||||||
|
|
||||||
ts.Close()
|
ts.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,20 +23,6 @@ func (e Role) String() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
SystemBotID int32 = 0
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
SystemBot = &User{
|
|
||||||
ID: SystemBotID,
|
|
||||||
Username: "system_bot",
|
|
||||||
Role: RoleAdmin,
|
|
||||||
Email: "",
|
|
||||||
Nickname: "Bot",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
ID int32
|
ID int32
|
||||||
|
|
||||||
|
|
@ -125,9 +111,6 @@ func (s *Store) ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
|
||||||
|
|
||||||
func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error) {
|
func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error) {
|
||||||
if find.ID != nil {
|
if find.ID != nil {
|
||||||
if *find.ID == SystemBotID {
|
|
||||||
return SystemBot, nil
|
|
||||||
}
|
|
||||||
if cache, ok := s.userCache.Get(ctx, string(*find.ID)); ok {
|
if cache, ok := s.userCache.Get(ctx, string(*find.ID)); ok {
|
||||||
user, ok := cache.(*User)
|
user, ok := cache.(*User)
|
||||||
if ok {
|
if ok {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue