aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
authordevonh <devon.dmytro@gmail.com>2023-09-15 15:25:09 +0000
committerGitHub <noreply@github.com>2023-09-15 15:25:09 +0000
commitdb83789654ade3cf4f900e8fbcaa742b60c5dc6c (patch)
treeb68208908a4e73dba7fde6c72b91c52a47f8d018 /clientapi
parent8245b24100b0afaa046bb3fe52f0994f906c8ab1 (diff)
Move pseudoID ClientEvent hotswapping to a common location (#3199)
Fixes a variety of issues where clients were receiving pseudoIDs in places that should be userIDs. This change makes pseudoIDs work with sliding sync & element x. --------- Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com>
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/routing/state.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/clientapi/routing/state.go b/clientapi/routing/state.go
index 6f363349..18f9a0e9 100644
--- a/clientapi/routing/state.go
+++ b/clientapi/routing/state.go
@@ -172,23 +172,16 @@ func OnIncomingStateRequest(ctx context.Context, device *userapi.Device, rsAPI a
}
}
for _, ev := range stateAfterRes.StateEvents {
- sender := spec.UserID{}
- userID, err := rsAPI.QueryUserIDForSender(ctx, ev.RoomID(), ev.SenderID())
- if err == nil && userID != nil {
- sender = *userID
- }
-
- sk := ev.StateKey()
- if sk != nil && *sk != "" {
- skUserID, err := rsAPI.QueryUserIDForSender(ctx, ev.RoomID(), spec.SenderID(*ev.StateKey()))
- if err == nil && skUserID != nil {
- skString := skUserID.String()
- sk = &skString
- }
+ clientEvent, err := synctypes.ToClientEvent(ev, synctypes.FormatAll, func(roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error) {
+ return rsAPI.QueryUserIDForSender(ctx, roomID, senderID)
+ })
+ if err != nil {
+ util.GetLogger(ctx).WithError(err).Error("Failed converting to ClientEvent")
+ continue
}
stateEvents = append(
stateEvents,
- synctypes.ToClientEvent(ev, synctypes.FormatAll, sender.String(), sk, ev.Unsigned()),
+ *clientEvent,
)
}
}