MM-59827: Remove user profile invalidations from channel APIs (#27720)
We were invalidating the userProfileByIds cache unnecessarily when it wasn't really needed. It's just that the InvalidateCacheForUser method wiped off all user related caches, when we just needed to wipe user-channel related caches. To fix this, we split the user cache invalidation method into two and just call the InvalidateChannelCacheForUser method from app/channel.go. https://mattermost.atlassian.net/browse/MM-59827 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
db626377bf
Коммит
3150900bd7
@@ -288,7 +288,7 @@ func (a *App) CreateChannel(c request.CTX, channel *model.Channel, addMember boo
|
||||
return nil, model.NewAppError("CreateChannel", "app.channel_member_history.log_join_event.internal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(channel.CreatorId)
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(channel.CreatorId)
|
||||
}
|
||||
|
||||
a.Srv().Go(func() {
|
||||
@@ -372,8 +372,8 @@ func (a *App) getOrCreateDirectChannelWithUser(c request.CTX, user, otherUser *m
|
||||
}
|
||||
|
||||
func (a *App) handleCreationEvent(c request.CTX, userID, otherUserID string, channel *model.Channel) {
|
||||
a.InvalidateCacheForUser(userID)
|
||||
a.InvalidateCacheForUser(otherUserID)
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(userID)
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(otherUserID)
|
||||
|
||||
a.Srv().Go(func() {
|
||||
pluginContext := pluginContext(c)
|
||||
@@ -499,7 +499,7 @@ func (a *App) CreateGroupChannel(c request.CTX, userIDs []string, creatorId stri
|
||||
|
||||
jsonIDs := model.ArrayToJSON(userIDs)
|
||||
for _, userID := range userIDs {
|
||||
a.InvalidateCacheForUser(userID)
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(userID)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WebsocketEventGroupAdded, "", channel.Id, userID, nil, "")
|
||||
message.Add("teammate_ids", jsonIDs)
|
||||
@@ -1294,7 +1294,7 @@ func (a *App) UpdateChannelMemberNotifyProps(c request.CTX, data map[string]stri
|
||||
}
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(member.UserId)
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(member.UserId)
|
||||
a.invalidateCacheForChannelMembersNotifyProps(member.ChannelId)
|
||||
|
||||
// Notify the clients that the member notify props changed
|
||||
@@ -1331,7 +1331,7 @@ func (a *App) PatchChannelMembersNotifyProps(c request.CTX, members []*model.Cha
|
||||
}
|
||||
|
||||
for userId := range userIds {
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(userId)
|
||||
}
|
||||
for channelId := range channelIds {
|
||||
a.invalidateCacheForChannelMembersNotifyProps(channelId)
|
||||
@@ -1375,7 +1375,7 @@ func (a *App) updateChannelMember(c request.CTX, member *model.ChannelMember) (*
|
||||
}
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(member.UserId)
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(member.UserId)
|
||||
|
||||
// Notify the clients that the member notify props changed
|
||||
evt := model.NewWebSocketEvent(model.WebsocketEventChannelMemberUpdated, "", "", member.UserId, nil, "")
|
||||
@@ -1568,7 +1568,7 @@ func (a *App) addUserToChannel(c request.CTX, user *model.User, channel *model.C
|
||||
return nil, model.NewAppError("AddUserToChannel", "app.channel_member_history.log_join_event.internal_error", nil, "", http.StatusInternalServerError).Wrap(nErr)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(user.Id)
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
|
||||
return newMember, nil
|
||||
@@ -2562,7 +2562,7 @@ func (a *App) removeUserFromChannel(c request.CTX, userIDToRemove string, remove
|
||||
}
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userIDToRemove)
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(userIDToRemove)
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
|
||||
var actorUser *model.User
|
||||
|
||||
@@ -196,11 +196,15 @@ func (ps *PlatformService) InvalidateCacheForChannelPosts(channelID string) {
|
||||
}
|
||||
|
||||
func (ps *PlatformService) InvalidateCacheForUser(userID string) {
|
||||
ps.InvalidateChannelCacheForUser(userID)
|
||||
ps.Store.User().InvalidateProfileCacheForUser(userID)
|
||||
}
|
||||
|
||||
func (ps *PlatformService) InvalidateChannelCacheForUser(userID string) {
|
||||
ps.Store.Channel().InvalidateAllChannelMembersForUser(userID)
|
||||
ps.ClearUserSessionCache(userID)
|
||||
|
||||
ps.Store.User().InvalidateProfilesInChannelCacheByUser(userID)
|
||||
ps.Store.User().InvalidateProfileCacheForUser(userID)
|
||||
}
|
||||
|
||||
func (ps *PlatformService) InvalidateCacheForUserTeams(userID string) {
|
||||
|
||||
Ссылка в новой задаче
Block a user