* MM-67522 Add tests for syncing user statuses (#35269) * MM-67522 Add tests for syncing user statuses * Clean up newly added tests * Fix style * Use SyncResponse.StatusErrors when statuses fail to sync (cherry picked from commit 033867a3448875d84653c81026d31bddf3ce4c40) * Rename rctx to c --------- Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a8d44e5918
Коммит
8b7e26fa13
@@ -263,7 +263,13 @@ func (scs *Service) processSyncMessage(c request.CTX, syncMsg *model.SyncMsg, rc
|
||||
}
|
||||
|
||||
for _, status := range syncMsg.Statuses {
|
||||
scs.app.SaveAndBroadcastStatus(status)
|
||||
if err := scs.upsertSyncUserStatus(c, status, rc); err != nil {
|
||||
scs.server.Log().Log(mlog.LvlSharedChannelServiceError, "Error upserting sync user status",
|
||||
mlog.String("remote", rc.Name),
|
||||
mlog.String("user_id", status.UserId),
|
||||
mlog.Err(err))
|
||||
syncResp.StatusErrors = append(syncResp.StatusErrors, status.UserId)
|
||||
}
|
||||
}
|
||||
|
||||
// Process membership changes after users have been synced
|
||||
@@ -754,6 +760,26 @@ func (scs *Service) upsertSyncAcknowledgement(acknowledgement *model.PostAcknowl
|
||||
return savedAcknowledgement, retErr
|
||||
}
|
||||
|
||||
func (scs *Service) upsertSyncUserStatus(rctx request.CTX, status *model.Status, rc *model.RemoteCluster) error {
|
||||
user, err := scs.server.GetStore().User().Get(rctx.Context(), status.UserId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting user when syncing status: %w", err)
|
||||
}
|
||||
|
||||
if user.GetRemoteID() != rc.RemoteId {
|
||||
scs.server.Log().Log(mlog.LvlSharedChannelServiceError, "RemoteID mismatch sync'ing user status",
|
||||
mlog.String("remote", rc.Name),
|
||||
mlog.String("user_id", status.UserId),
|
||||
mlog.String("user_remote_id", user.GetRemoteID()),
|
||||
)
|
||||
return fmt.Errorf("error updating user status: %w", ErrRemoteIDMismatch)
|
||||
}
|
||||
|
||||
scs.app.SaveAndBroadcastStatus(status)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// transformMentionsOnReceive transforms mentions in received posts using explicit mentionTransforms.
|
||||
func (scs *Service) transformMentionsOnReceive(rctx request.CTX, post *model.Post, targetChannel *model.Channel, rc *model.RemoteCluster, mentionTransforms map[string]string) {
|
||||
if post.Message == "" || len(mentionTransforms) == 0 {
|
||||
|
||||
Ссылка в новой задаче
Block a user