fix: sync moderation refresh cache bypass
This commit is contained in:
parent
3dd9c345d7
commit
6cafa40c7b
6 changed files with 187 additions and 0 deletions
|
|
@ -3,6 +3,8 @@ package rpc
|
|||
import (
|
||||
"context"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
|
|
@ -25,6 +27,38 @@ func (r *Router) enrichUpdateEventsWithPeerCache(ctx context.Context, viewerUser
|
|||
allUserIDs := make(map[int64]struct{})
|
||||
allChannelIDs := make(map[int64]struct{})
|
||||
for i := range out {
|
||||
if out[i].Type == domain.UpdateEventUserProfile {
|
||||
if service, ok := r.deps.Users.(UserAuthoritativeProjectionService); ok {
|
||||
users, err := service.ByIDsAuthoritative(ctx, viewerUserID, []int64{out[i].Peer.ID})
|
||||
if err != nil {
|
||||
r.log.Warn("reload authoritative user profile event",
|
||||
zap.Int64("viewer_user_id", viewerUserID),
|
||||
zap.Int64("target_user_id", out[i].Peer.ID),
|
||||
zap.Error(err))
|
||||
} else {
|
||||
out[i].Users = users
|
||||
cache.primeUsers(viewerUserID, users)
|
||||
}
|
||||
}
|
||||
}
|
||||
if out[i].Type == domain.UpdateEventChannelState {
|
||||
if service, ok := r.deps.Channels.(ChannelAuthoritativeProjectionService); ok {
|
||||
views, err := service.GetChannelsAuthoritative(ctx, viewerUserID, []int64{out[i].Peer.ID})
|
||||
if err != nil {
|
||||
r.log.Warn("reload authoritative channel state event",
|
||||
zap.Int64("viewer_user_id", viewerUserID),
|
||||
zap.Int64("channel_id", out[i].Peer.ID),
|
||||
zap.Error(err))
|
||||
} else {
|
||||
out[i].Channels = out[i].Channels[:0]
|
||||
for _, view := range views {
|
||||
if view.Channel.ID != 0 {
|
||||
out[i].Channels = append(out[i].Channels, view.Channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if out[i].Type == domain.UpdateEventMessageReactions {
|
||||
out[i] = r.enrichMessageReactionEvent(ctx, viewerUserID, out[i])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue