Send user updated websocket event on plugin.UpdateUser (#16604)

* Send user updated websocket event on plugin.UpdateUser

* Changes from review
This commit is contained in:
Chetanya Kandhari
2021-02-04 10:19:32 +05:30
committed by GitHub
parent e77a3923c9
commit 78ccf8a775
4 changed files with 7 additions and 10 deletions

View File

@@ -1018,7 +1018,7 @@ type AppIface interface {
UpdateUserActive(userId string, active bool) *model.AppError
UpdateUserAsUser(user *model.User, asAdmin bool) (*model.User, *model.AppError)
UpdateUserAuth(userId string, userAuth *model.UserAuth) (*model.UserAuth, *model.AppError)
UpdateUserNotifyProps(userId string, props map[string]string) (*model.User, *model.AppError)
UpdateUserNotifyProps(userId string, props map[string]string, sendNotifications bool) (*model.User, *model.AppError)
UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent bool) (*model.User, *model.AppError)
UploadData(us *model.UploadSession, rd io.Reader) (*model.FileInfo, *model.AppError)
UploadEmojiImage(id string, imageData *multipart.FileHeader) *model.AppError

View File

@@ -493,7 +493,7 @@ func (a *App) importUser(data *UserImportData, dryRun bool) *model.AppError {
}
}
if hasNotifyPropsChanged {
if savedUser, err = a.UpdateUserNotifyProps(user.Id, user.NotifyProps); err != nil {
if savedUser, err = a.UpdateUserNotifyProps(user.Id, user.NotifyProps, false); err != nil {
return err
}
}

View File

@@ -15622,7 +15622,7 @@ func (a *OpenTracingAppLayer) UpdateUserAuth(userId string, userAuth *model.User
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) UpdateUserNotifyProps(userId string, props map[string]string) (*model.User, *model.AppError) {
func (a *OpenTracingAppLayer) UpdateUserNotifyProps(userId string, props map[string]string, sendNotifications bool) (*model.User, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.UpdateUserNotifyProps")
@@ -15634,7 +15634,7 @@ func (a *OpenTracingAppLayer) UpdateUserNotifyProps(userId string, props map[str
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.UpdateUserNotifyProps(userId, props)
resultVar0, resultVar1 := a.app.UpdateUserNotifyProps(userId, props, sendNotifications)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))

View File

@@ -1174,8 +1174,6 @@ func (a *App) UpdateUserAsUser(user *model.User, asAdmin bool) (*model.User, *mo
return nil, err
}
a.sendUpdatedUserEvent(*updatedUser)
return updatedUser, nil
}
@@ -1192,8 +1190,6 @@ func (a *App) PatchUser(userId string, patch *model.UserPatch, asAdmin bool) (*m
return nil, err
}
a.sendUpdatedUserEvent(*updatedUser)
return updatedUser, nil
}
@@ -1311,6 +1307,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
}
})
}
a.sendUpdatedUserEvent(*userUpdate.New)
}
a.InvalidateCacheForUser(user.Id)
@@ -1331,7 +1328,7 @@ func (a *App) UpdateUserActive(userId string, active bool) *model.AppError {
return nil
}
func (a *App) UpdateUserNotifyProps(userId string, props map[string]string) (*model.User, *model.AppError) {
func (a *App) UpdateUserNotifyProps(userId string, props map[string]string, sendNotifications bool) (*model.User, *model.AppError) {
user, err := a.GetUser(userId)
if err != nil {
return nil, err
@@ -1339,7 +1336,7 @@ func (a *App) UpdateUserNotifyProps(userId string, props map[string]string) (*mo
user.NotifyProps = props
ruser, err := a.UpdateUser(user, true)
ruser, err := a.UpdateUser(user, sendNotifications)
if err != nil {
return nil, err
}