[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
Этот коммит содержится в:
jfrerich
2019-10-31 11:25:19 -05:00
коммит произвёл GitHub
родитель 422f377c96
Коммит f3716caba9
2 изменённых файлов: 9 добавлений и 1 удалений

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

@@ -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"