MM-56881 Validate and ensure valid CustomStatus is stored (#26287)

* don't allow invalid CustomStatus

* allow empty emoji in custom status

* lint fix

* add english translation

* update for review comments.

* fix bad fix

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Scott Bishel
2024-03-04 15:53:55 -07:00
коммит произвёл GitHub
родитель 5740b43922
Коммит 30454f241d
7 изменённых файлов: 78 добавлений и 8 удалений

Просмотреть файл

@@ -355,3 +355,24 @@ func TestUserSlice(t *testing.T) {
assert.Len(t, nonBotUsers, 1)
})
}
func TestValidateCustomStatus(t *testing.T) {
t.Run("ValidateCustomStatus", func(t *testing.T) {
user0 := &User{Id: "user0", DeleteAt: 0, IsBot: true}
user0.Props = map[string]string{UserPropsKeyCustomStatus: ""}
assert.True(t, user0.ValidateCustomStatus())
user0.Props[UserPropsKeyCustomStatus] = "hello"
assert.False(t, user0.ValidateCustomStatus())
user0.Props[UserPropsKeyCustomStatus] = "{\"emoji\":{\"foo\":\"bar\"}}"
assert.True(t, user0.ValidateCustomStatus())
user0.Props[UserPropsKeyCustomStatus] = "{\"text\": \"hello\"}"
assert.True(t, user0.ValidateCustomStatus())
user0.Props[UserPropsKeyCustomStatus] = "{\"wrong\": \"hello\"}"
assert.True(t, user0.ValidateCustomStatus())
})
}