MM-15452 - Add ability to override LHS icon for bot accounts (#11423)
* MM-15452 - Add ability to override LHS icon for bot accounts * MM-15452 - Added translations * MM-15452 - Updated GetIconImage test to check returned image * MM-15452 - Added Delete handler for /icon endpoint, invalidating user cache on set/delete * MM-15452 - Moved /icon routes under bot/, addressed other pr feedback * MM-15452 - More conflict resolutoin * MM-15452 Restoring api4/user.go * MM-15452 - Using require as opposed to t for test assertions * MM-15452 - Updated as per PR feedback
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
0d05fe32af
Коммит
2ecca12bed
34
app/user.go
34
app/user.go
@@ -899,21 +899,7 @@ func (a *App) SetProfileImageFromFile(userId string, file io.Reader) *model.AppE
|
||||
if err := a.Srv.Store.User().UpdateLastPictureUpdate(userId); err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
|
||||
user, userErr := a.GetUser(userId)
|
||||
if userErr != nil {
|
||||
mlog.Error(fmt.Sprintf("Error in getting users profile for id=%v forcing logout", userId), mlog.String("user_id", userId))
|
||||
return nil
|
||||
}
|
||||
|
||||
options := a.Config().GetSanitizeOptions()
|
||||
user.SanitizeProfile(options)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_UPDATED, "", "", "", nil)
|
||||
message.Add("user", user)
|
||||
a.Publish(message)
|
||||
a.invalidateUserCacheAndPublish(userId)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -2227,3 +2213,21 @@ func (a *App) getListOfAllowedChannelsForTeam(teamId string, viewRestrictions *m
|
||||
|
||||
return listOfAllowedChannels, nil
|
||||
}
|
||||
|
||||
// invalidateUserCacheAndPublish Invalidates cache for a user and publishes user updated event
|
||||
func (a *App) invalidateUserCacheAndPublish(userId string) {
|
||||
a.InvalidateCacheForUser(userId)
|
||||
|
||||
user, userErr := a.GetUser(userId)
|
||||
if userErr != nil {
|
||||
mlog.Error(fmt.Sprintf("Error in getting users profile for id=%v, err=%v", userId, userErr.Error()), mlog.String("user_id", userId))
|
||||
return
|
||||
}
|
||||
|
||||
options := a.Config().GetSanitizeOptions()
|
||||
user.SanitizeProfile(options)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_UPDATED, "", "", "", nil)
|
||||
message.Add("user", user)
|
||||
a.Publish(message)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user