Send user updated websocket event on plugin.UpdateUser (#16604)
* Send user updated websocket event on plugin.UpdateUser * Changes from review
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e77a3923c9
Коммит
78ccf8a775
@@ -1018,7 +1018,7 @@ type AppIface interface {
|
|||||||
UpdateUserActive(userId string, active bool) *model.AppError
|
UpdateUserActive(userId string, active bool) *model.AppError
|
||||||
UpdateUserAsUser(user *model.User, asAdmin bool) (*model.User, *model.AppError)
|
UpdateUserAsUser(user *model.User, asAdmin bool) (*model.User, *model.AppError)
|
||||||
UpdateUserAuth(userId string, userAuth *model.UserAuth) (*model.UserAuth, *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)
|
UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent bool) (*model.User, *model.AppError)
|
||||||
UploadData(us *model.UploadSession, rd io.Reader) (*model.FileInfo, *model.AppError)
|
UploadData(us *model.UploadSession, rd io.Reader) (*model.FileInfo, *model.AppError)
|
||||||
UploadEmojiImage(id string, imageData *multipart.FileHeader) *model.AppError
|
UploadEmojiImage(id string, imageData *multipart.FileHeader) *model.AppError
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ func (a *App) importUser(data *UserImportData, dryRun bool) *model.AppError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if hasNotifyPropsChanged {
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15622,7 +15622,7 @@ func (a *OpenTracingAppLayer) UpdateUserAuth(userId string, userAuth *model.User
|
|||||||
return resultVar0, resultVar1
|
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
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.UpdateUserNotifyProps")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.UpdateUserNotifyProps")
|
||||||
|
|
||||||
@@ -15634,7 +15634,7 @@ func (a *OpenTracingAppLayer) UpdateUserNotifyProps(userId string, props map[str
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
resultVar0, resultVar1 := a.app.UpdateUserNotifyProps(userId, props)
|
resultVar0, resultVar1 := a.app.UpdateUserNotifyProps(userId, props, sendNotifications)
|
||||||
|
|
||||||
if resultVar1 != nil {
|
if resultVar1 != nil {
|
||||||
span.LogFields(spanlog.Error(resultVar1))
|
span.LogFields(spanlog.Error(resultVar1))
|
||||||
|
|||||||
@@ -1174,8 +1174,6 @@ func (a *App) UpdateUserAsUser(user *model.User, asAdmin bool) (*model.User, *mo
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
a.sendUpdatedUserEvent(*updatedUser)
|
|
||||||
|
|
||||||
return updatedUser, nil
|
return updatedUser, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1192,8 +1190,6 @@ func (a *App) PatchUser(userId string, patch *model.UserPatch, asAdmin bool) (*m
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
a.sendUpdatedUserEvent(*updatedUser)
|
|
||||||
|
|
||||||
return updatedUser, nil
|
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)
|
a.InvalidateCacheForUser(user.Id)
|
||||||
@@ -1331,7 +1328,7 @@ func (a *App) UpdateUserActive(userId string, active bool) *model.AppError {
|
|||||||
return nil
|
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)
|
user, err := a.GetUser(userId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1339,7 +1336,7 @@ func (a *App) UpdateUserNotifyProps(userId string, props map[string]string) (*mo
|
|||||||
|
|
||||||
user.NotifyProps = props
|
user.NotifyProps = props
|
||||||
|
|
||||||
ruser, err := a.UpdateUser(user, true)
|
ruser, err := a.UpdateUser(user, sendNotifications)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user