Adding bot description field to bot users. (#11066)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f91dc57b4c
Коммит
69076934ec
@@ -83,6 +83,7 @@ type User struct {
|
|||||||
MfaSecret string `json:"mfa_secret,omitempty"`
|
MfaSecret string `json:"mfa_secret,omitempty"`
|
||||||
LastActivityAt int64 `db:"-" json:"last_activity_at,omitempty"`
|
LastActivityAt int64 `db:"-" json:"last_activity_at,omitempty"`
|
||||||
IsBot bool `db:"-" json:"is_bot,omitempty"`
|
IsBot bool `db:"-" json:"is_bot,omitempty"`
|
||||||
|
BotDescription string `db:"-" json:"bot_description,omitempty"`
|
||||||
TermsOfServiceId string `db:"-" json:"terms_of_service_id,omitempty"`
|
TermsOfServiceId string `db:"-" json:"terms_of_service_id,omitempty"`
|
||||||
TermsOfServiceCreateAt int64 `db:"-" json:"terms_of_service_create_at,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().
|
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").
|
From("Users u").
|
||||||
LeftJoin("Bots b ON ( b.UserId = u.Id )")
|
LeftJoin("Bots b ON ( b.UserId = u.Id )")
|
||||||
|
|
||||||
|
|||||||
@@ -258,11 +258,13 @@ func testUserStoreGet(t *testing.T, ss store.Store) {
|
|||||||
Username: model.NewId(),
|
Username: model.NewId(),
|
||||||
})).(*model.User)
|
})).(*model.User)
|
||||||
store.Must(ss.Bot().Save(&model.Bot{
|
store.Must(ss.Bot().Save(&model.Bot{
|
||||||
UserId: u2.Id,
|
UserId: u2.Id,
|
||||||
Username: u2.Username,
|
Username: u2.Username,
|
||||||
OwnerId: u1.Id,
|
Description: "bot description",
|
||||||
|
OwnerId: u1.Id,
|
||||||
}))
|
}))
|
||||||
u2.IsBot = true
|
u2.IsBot = true
|
||||||
|
u2.BotDescription = "bot description"
|
||||||
defer func() { store.Must(ss.Bot().PermanentDelete(u2.Id)) }()
|
defer func() { store.Must(ss.Bot().PermanentDelete(u2.Id)) }()
|
||||||
defer func() { require.Nil(t, ss.User().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.Nil(t, err)
|
||||||
require.Equal(t, u2, actual)
|
require.Equal(t, u2, actual)
|
||||||
require.True(t, actual.IsBot)
|
require.True(t, actual.IsBot)
|
||||||
|
require.Equal(t, "bot description", actual.BotDescription)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user