mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Adding bot description field to bot users. (#11066)
This commit is contained in:
committed by
GitHub
parent
f91dc57b4c
commit
69076934ec
@@ -83,6 +83,7 @@ type User struct {
|
||||
MfaSecret string `json:"mfa_secret,omitempty"`
|
||||
LastActivityAt int64 `db:"-" json:"last_activity_at,omitempty"`
|
||||
IsBot bool `db:"-" json:"is_bot,omitempty"`
|
||||
BotDescription string `db:"-" json:"bot_description,omitempty"`
|
||||
TermsOfServiceId string `db:"-" json:"terms_of_service_id,omitempty"`
|
||||
TermsOfServiceCreateAt int64 `db:"-" json:"terms_of_service_create_at,omitempty"`
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func NewSqlUserStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) st
|
||||
}
|
||||
|
||||
us.usersQuery = us.getQueryBuilder().
|
||||
Select("u.*", "b.UserId IS NOT NULL AS IsBot").
|
||||
Select("u.*", "b.UserId IS NOT NULL AS IsBot", "COALESCE(b.Description, '') AS BotDescription").
|
||||
From("Users u").
|
||||
LeftJoin("Bots b ON ( b.UserId = u.Id )")
|
||||
|
||||
|
||||
@@ -258,11 +258,13 @@ func testUserStoreGet(t *testing.T, ss store.Store) {
|
||||
Username: model.NewId(),
|
||||
})).(*model.User)
|
||||
store.Must(ss.Bot().Save(&model.Bot{
|
||||
UserId: u2.Id,
|
||||
Username: u2.Username,
|
||||
OwnerId: u1.Id,
|
||||
UserId: u2.Id,
|
||||
Username: u2.Username,
|
||||
Description: "bot description",
|
||||
OwnerId: u1.Id,
|
||||
}))
|
||||
u2.IsBot = true
|
||||
u2.BotDescription = "bot description"
|
||||
defer func() { store.Must(ss.Bot().PermanentDelete(u2.Id)) }()
|
||||
defer func() { require.Nil(t, ss.User().PermanentDelete(u2.Id)) }()
|
||||
|
||||
@@ -285,6 +287,7 @@ func testUserStoreGet(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, u2, actual)
|
||||
require.True(t, actual.IsBot)
|
||||
require.Equal(t, "bot description", actual.BotDescription)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user