[MM-55595] Use annotated logger in search layer (#25468)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5a4dba8809
Коммит
b2ec1ff8ae
@@ -885,7 +885,7 @@ func (a *App) SetProfileImageFromFile(c request.CTX, userID string, file io.Read
|
||||
if err := a.Srv().Store().User().UpdateLastPictureUpdate(userID); err != nil {
|
||||
c.Logger().Warn("Error with updating last picture update", mlog.Err(err))
|
||||
}
|
||||
a.invalidateUserCacheAndPublish(userID)
|
||||
a.invalidateUserCacheAndPublish(c, userID)
|
||||
a.onUserProfileChange(userID)
|
||||
|
||||
return nil
|
||||
@@ -937,7 +937,7 @@ func (a *App) userDeactivated(c request.CTX, userID string) *model.AppError {
|
||||
}
|
||||
|
||||
if nErr := a.Srv().Store().OAuth().RemoveAuthDataByUserId(userID); nErr != nil {
|
||||
mlog.Warn("unable to remove auth data by user id", mlog.Err(nErr))
|
||||
c.Logger().Warn("unable to remove auth data by user id", mlog.Err(nErr))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -974,7 +974,7 @@ func (a *App) UpdateActive(c request.CTX, user *model.User, active bool) (*model
|
||||
user.DeleteAt = user.UpdateAt
|
||||
}
|
||||
|
||||
userUpdate, err := a.ch.srv.userService.UpdateUser(user, true)
|
||||
userUpdate, err := a.ch.srv.userService.UpdateUser(c, user, true)
|
||||
if err != nil {
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
@@ -1222,7 +1222,7 @@ func (a *App) UpdateUser(c request.CTX, user *model.User, sendNotifications bool
|
||||
}
|
||||
}
|
||||
|
||||
userUpdate, err := a.ch.srv.userService.UpdateUser(user, false)
|
||||
userUpdate, err := a.ch.srv.userService.UpdateUser(c, user, false)
|
||||
if err != nil {
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
@@ -1606,7 +1606,7 @@ func (a *App) UpdateUserRolesWithUser(c request.CTX, user *model.User, newRoles
|
||||
user.Roles = newRoles
|
||||
uchan := make(chan store.GenericStoreResult[*model.UserUpdate], 1)
|
||||
go func() {
|
||||
userUpdate, err := a.Srv().Store().User().Update(user, true)
|
||||
userUpdate, err := a.Srv().Store().User().Update(c, user, true)
|
||||
uchan <- store.GenericStoreResult[*model.UserUpdate]{Data: userUpdate, NErr: err}
|
||||
close(uchan)
|
||||
}()
|
||||
@@ -1689,7 +1689,7 @@ func (a *App) PermanentDeleteUser(c request.CTX, user *model.User) *model.AppErr
|
||||
return model.NewAppError("PermanentDeleteUser", "app.preference.permanent_delete_by_user.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store().Channel().PermanentDeleteMembersByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store().Channel().PermanentDeleteMembersByUser(c, user.Id); err != nil {
|
||||
return model.NewAppError("PermanentDeleteUser", "app.channel.permanent_delete_members_by_user.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
@@ -1697,7 +1697,7 @@ func (a *App) PermanentDeleteUser(c request.CTX, user *model.User) *model.AppErr
|
||||
return model.NewAppError("PermanentDeleteUser", "app.group.permanent_delete_members_by_user.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store().Post().PermanentDeleteByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store().Post().PermanentDeleteByUser(c, user.Id); err != nil {
|
||||
return model.NewAppError("PermanentDeleteUser", "app.post.permanent_delete_by_user.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
@@ -1756,7 +1756,7 @@ func (a *App) PermanentDeleteUser(c request.CTX, user *model.User) *model.AppErr
|
||||
|
||||
if errProfileImageExists != nil {
|
||||
fileHandlingErrorsFound = true
|
||||
mlog.Warn(
|
||||
c.Logger().Warn(
|
||||
"Error checking existence of profile image.",
|
||||
mlog.String("path", profileImagePath),
|
||||
mlog.Err(errProfileImageExists),
|
||||
@@ -1768,7 +1768,7 @@ func (a *App) PermanentDeleteUser(c request.CTX, user *model.User) *model.AppErr
|
||||
|
||||
if errRemoveDirectory != nil {
|
||||
fileHandlingErrorsFound = true
|
||||
mlog.Warn(
|
||||
c.Logger().Warn(
|
||||
"Unable to remove profile image directory",
|
||||
mlog.String("path", profileImageDirectory),
|
||||
mlog.Err(errRemoveDirectory),
|
||||
@@ -1776,7 +1776,7 @@ func (a *App) PermanentDeleteUser(c request.CTX, user *model.User) *model.AppErr
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := a.Srv().Store().FileInfo().PermanentDeleteByUser(user.Id); err != nil {
|
||||
if _, err := a.Srv().Store().FileInfo().PermanentDeleteByUser(c, user.Id); err != nil {
|
||||
return model.NewAppError("PermanentDeleteUser", "app.file_info.permanent_delete_by_user.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
@@ -1788,7 +1788,7 @@ func (a *App) PermanentDeleteUser(c request.CTX, user *model.User) *model.AppErr
|
||||
return model.NewAppError("PermanentDeleteUser", "app.audit.permanent_delete_by_user.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store().Team().RemoveAllMembersByUser(user.Id); err != nil {
|
||||
if err := a.Srv().Store().Team().RemoveAllMembersByUser(c, user.Id); err != nil {
|
||||
return model.NewAppError("PermanentDeleteUser", "app.team.remove_member.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
@@ -1877,7 +1877,7 @@ func (a *App) VerifyEmailFromToken(c request.CTX, userSuppliedTokenString string
|
||||
if user.Email != tokenData.Email {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.Srv().EmailService.SendEmailChangeEmail(user.Email, tokenData.Email, user.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send email change email", mlog.Err(err))
|
||||
c.Logger().Error("Failed to send email change email", mlog.Err(err))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1945,7 +1945,7 @@ func (a *App) VerifyUserEmail(userID, email string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SearchUsers(props *model.UserSearch, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (a *App) SearchUsers(rctx request.CTX, props *model.UserSearch, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
if props.WithoutTeam {
|
||||
return a.SearchUsersWithoutTeam(props.Term, options)
|
||||
}
|
||||
@@ -1964,7 +1964,7 @@ func (a *App) SearchUsers(props *model.UserSearch, options *model.UserSearchOpti
|
||||
if props.NotInGroupId != "" {
|
||||
return a.SearchUsersNotInGroup(props.NotInGroupId, props.Term, options)
|
||||
}
|
||||
return a.SearchUsersInTeam(props.TeamId, props.Term, options)
|
||||
return a.SearchUsersInTeam(rctx, props.TeamId, props.Term, options)
|
||||
}
|
||||
|
||||
func (a *App) SearchUsersInChannel(channelID string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
@@ -1994,10 +1994,10 @@ func (a *App) SearchUsersNotInChannel(teamID string, channelID string, term stri
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) SearchUsersInTeam(teamID, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
func (a *App) SearchUsersInTeam(rctx request.CTX, teamID, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
users, err := a.Srv().Store().User().Search(teamID, term, options)
|
||||
users, err := a.Srv().Store().User().Search(rctx, teamID, term, options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SearchUsersInTeam", "app.user.search.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
@@ -2065,10 +2065,10 @@ func (a *App) SearchUsersNotInGroup(groupID string, term string, options *model.
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (a *App) AutocompleteUsersInChannel(teamID string, channelID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError) {
|
||||
func (a *App) AutocompleteUsersInChannel(rctx request.CTX, teamID string, channelID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
autocomplete, err := a.Srv().Store().User().AutocompleteUsersInChannel(teamID, channelID, term, options)
|
||||
autocomplete, err := a.Srv().Store().User().AutocompleteUsersInChannel(rctx, teamID, channelID, term, options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("AutocompleteUsersInChannel", "app.user.search.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
@@ -2084,10 +2084,10 @@ func (a *App) AutocompleteUsersInChannel(teamID string, channelID string, term s
|
||||
return autocomplete, nil
|
||||
}
|
||||
|
||||
func (a *App) AutocompleteUsersInTeam(teamID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInTeam, *model.AppError) {
|
||||
func (a *App) AutocompleteUsersInTeam(rctx request.CTX, teamID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInTeam, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
users, err := a.Srv().Store().User().Search(teamID, term, options)
|
||||
users, err := a.Srv().Store().User().Search(rctx, teamID, term, options)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("AutocompleteUsersInTeam", "app.user.search.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
@@ -2136,7 +2136,7 @@ func (a *App) UpdateOAuthUserAttrs(c request.CTX, userData io.Reader, user *mode
|
||||
}
|
||||
|
||||
if userAttrsChanged {
|
||||
users, err := a.Srv().Store().User().Update(user, true)
|
||||
users, err := a.Srv().Store().User().Update(c, user, true)
|
||||
if err != nil {
|
||||
var appErr *model.AppError
|
||||
var invErr *store.ErrInvalidInput
|
||||
@@ -2417,12 +2417,12 @@ func (a *App) PublishUserTyping(userID, channelID, parentId string) *model.AppEr
|
||||
}
|
||||
|
||||
// invalidateUserCacheAndPublish Invalidates cache for a user and publishes user updated event
|
||||
func (a *App) invalidateUserCacheAndPublish(userID string) {
|
||||
func (a *App) invalidateUserCacheAndPublish(rctx request.CTX, userID string) {
|
||||
a.InvalidateCacheForUser(userID)
|
||||
|
||||
user, userErr := a.GetUser(userID)
|
||||
if userErr != nil {
|
||||
mlog.Error("Error in getting users profile", mlog.String("user_id", userID), mlog.Err(userErr))
|
||||
rctx.Logger().Error("Error in getting users profile", mlog.String("user_id", userID), mlog.Err(userErr))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user