From 54bb6d10f33ab599ea24b9080d0e289a50ade152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Wed, 4 Mar 2020 16:16:27 +0100 Subject: [PATCH] Making InvalidateCacheForUser public again (#13997) --- app/channel.go | 18 +++++++++--------- app/team.go | 4 ++-- app/user.go | 16 ++++++++-------- app/web_hub.go | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/channel.go b/app/channel.go index b5b5938222..aec6a3b2a1 100644 --- a/app/channel.go +++ b/app/channel.go @@ -254,7 +254,7 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan return nil, err } - a.invalidateCacheForUser(channel.CreatorId) + a.InvalidateCacheForUser(channel.CreatorId) } if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil { @@ -301,8 +301,8 @@ func (a *App) GetOrCreateDirectChannel(userId, otherUserId string) (*model.Chann a.WaitForChannelMembership(channel.Id, userId) - a.invalidateCacheForUser(userId) - a.invalidateCacheForUser(otherUserId) + a.InvalidateCacheForUser(userId) + a.InvalidateCacheForUser(otherUserId) if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil { a.Srv().Go(func() { @@ -424,7 +424,7 @@ func (a *App) CreateGroupChannel(userIds []string, creatorId string) (*model.Cha a.WaitForChannelMembership(channel.Id, creatorId) } - a.invalidateCacheForUser(userId) + a.InvalidateCacheForUser(userId) } message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_GROUP_ADDED, "", channel.Id, "", nil) @@ -777,7 +777,7 @@ func (a *App) UpdateChannelMemberRoles(channelId string, userId string, newRoles return nil, err } - a.invalidateCacheForUser(userId) + a.InvalidateCacheForUser(userId) return member, nil } @@ -810,7 +810,7 @@ func (a *App) UpdateChannelMemberSchemeRoles(channelId string, userId string, is message.Add("channelMember", member.ToJson()) a.Publish(message) - a.invalidateCacheForUser(userId) + a.InvalidateCacheForUser(userId) return member, nil } @@ -847,7 +847,7 @@ func (a *App) UpdateChannelMemberNotifyProps(data map[string]string, channelId s return nil, err } - a.invalidateCacheForUser(userId) + a.InvalidateCacheForUser(userId) a.invalidateCacheForChannelMembersNotifyProps(channelId) // Notify the clients that the member notify props changed evt := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_MEMBER_UPDATED, "", "", userId, nil) @@ -1003,7 +1003,7 @@ func (a *App) addUserToChannel(user *model.User, channel *model.Channel, teamMem return nil, err } - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) a.invalidateCacheForChannelMembers(channel.Id) return newMember, nil @@ -1735,7 +1735,7 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string, } } - a.invalidateCacheForUser(userIdToRemove) + a.InvalidateCacheForUser(userIdToRemove) a.invalidateCacheForChannelMembers(channel.Id) if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil { diff --git a/app/team.go b/app/team.go index 61d329c16d..bab9bb4cd5 100644 --- a/app/team.go +++ b/app/team.go @@ -647,7 +647,7 @@ func (a *App) JoinUserToTeam(team *model.Team, user *model.User, userRequestorId } a.ClearSessionCacheForUser(user.Id) - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) a.invalidateCacheForUserTeams(user.Id) message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_ADDED_TO_TEAM, "", "", user.Id, nil) @@ -963,7 +963,7 @@ func (a *App) RemoveTeamMemberFromTeam(teamMember *model.TeamMember, requestorId } a.ClearSessionCacheForUser(user.Id) - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) a.invalidateCacheForUserTeams(user.Id) return nil diff --git a/app/user.go b/app/user.go index bcc24b4baf..03f7294c25 100644 --- a/app/user.go +++ b/app/user.go @@ -838,7 +838,7 @@ func (a *App) SetDefaultProfileImage(user *model.User) *model.AppError { mlog.Error("Failed to reset last picture update", mlog.Err(err)) } - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) updatedUser, appErr := a.GetUser(user.Id) if appErr != nil { @@ -1010,7 +1010,7 @@ func (a *App) UpdateActive(user *model.User, active bool) (*model.User, *model.A } a.invalidateUserChannelMembersCaches(user.Id) - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) a.sendUpdatedUserEvent(*ruser) @@ -1191,7 +1191,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User, } } - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) if a.IsESIndexingEnabled() { a.Srv().Go(func() { @@ -1437,7 +1437,7 @@ func (a *App) UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent mlog.Error("Failed during updating user roles", mlog.Err(result.Err)) } - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) a.ClearSessionCacheForUser(user.Id) if sendWebSocketEvent { @@ -2043,7 +2043,7 @@ func (a *App) UpdateOAuthUserAttrs(userData io.Reader, user *model.User, provide } user = users.New - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) if a.IsESIndexingEnabled() { a.Srv().Go(func() { @@ -2253,7 +2253,7 @@ func (a *App) getListOfAllowedChannelsForTeam(teamId string, viewRestrictions *m // guest roles to regular user roles. func (a *App) PromoteGuestToUser(user *model.User, requestorId string) *model.AppError { err := a.Srv().Store.User().PromoteGuestToUser(user.Id) - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) if err != nil { return err } @@ -2307,7 +2307,7 @@ func (a *App) PromoteGuestToUser(user *model.User, requestorId string) *model.Ap // regular user roles to guest roles. func (a *App) DemoteUserToGuest(user *model.User) *model.AppError { err := a.Srv().Store.User().DemoteUserToGuest(user.Id) - a.invalidateCacheForUser(user.Id) + a.InvalidateCacheForUser(user.Id) if err != nil { return err } @@ -2349,7 +2349,7 @@ func (a *App) DemoteUserToGuest(user *model.User) *model.AppError { // invalidateUserCacheAndPublish Invalidates cache for a user and publishes user updated event func (a *App) invalidateUserCacheAndPublish(userId string) { - a.invalidateCacheForUser(userId) + a.InvalidateCacheForUser(userId) user, userErr := a.GetUser(userId) if userErr != nil { diff --git a/app/web_hub.go b/app/web_hub.go index 304a1f824b..47eaca3885 100644 --- a/app/web_hub.go +++ b/app/web_hub.go @@ -269,7 +269,7 @@ func (a *App) invalidateCacheForChannelPosts(channelId string) { a.Srv().Store.Post().InvalidateLastPostTimeCache(channelId) } -func (a *App) invalidateCacheForUser(userId string) { +func (a *App) InvalidateCacheForUser(userId string) { a.invalidateCacheForUserSkipClusterSend(userId) a.Srv().Store.User().InvalidateProfilesInChannelCacheByUser(userId)