[MM-18331] When patching a bot send websocket notification (#12373)
* When patching a bot, perform these two additional steps: 1. Update the user.UpdateAt value for the user/bot. 2. send the websocket event so all clients know a user update has occured. This will tell clients to update the displayname * Add check for UpdateAt. Check that createdBot.UpdateAt is not equal to patchedBot.UpdateAt * re-add unintentional empty line delete in previous commit * Don't create a fake updateAt time. Let the Update() method handle the change. User the returned updateUser for sending updated user event
Этот коммит содержится в:
@@ -77,10 +77,15 @@ func (a *App) PatchBot(botUserId string, botPatch *model.BotPatch) (*model.Bot,
|
||||
user.Username = patchedUser.Username
|
||||
user.Email = patchedUser.Email
|
||||
user.FirstName = patchedUser.FirstName
|
||||
if _, err := a.Srv.Store.User().Update(user, true); err != nil {
|
||||
|
||||
userUpdate, err := a.Srv.Store.User().Update(user, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ruser := userUpdate.New
|
||||
a.sendUpdatedUserEvent(*ruser)
|
||||
|
||||
return a.Srv.Store.Bot().Update(bot)
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,9 @@ func TestPatchBot(t *testing.T) {
|
||||
patchedBot, err := th.App.PatchBot(createdBot.UserId, botPatch)
|
||||
require.Nil(t, err)
|
||||
|
||||
// patchedBot should create a new .UpdateAt time
|
||||
require.NotEqual(t, createdBot.UpdateAt, patchedBot.UpdateAt)
|
||||
|
||||
createdBot.Username = "username2"
|
||||
createdBot.DisplayName = "updated bot"
|
||||
createdBot.Description = "an updated bot"
|
||||
|
||||
Ссылка в новой задаче
Block a user