mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
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>
This commit is contained in:
parent
8245b24100
commit
db83789654
13 changed files with 426 additions and 333 deletions
|
@ -23,6 +23,14 @@ import (
|
|||
userUtil "github.com/matrix-org/dendrite/userapi/util"
|
||||
)
|
||||
|
||||
func queryUserIDForSender(senderID spec.SenderID) (*spec.UserID, error) {
|
||||
if senderID == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return spec.NewUserID(string(senderID), true)
|
||||
}
|
||||
|
||||
func TestNotifyUserCountsAsync(t *testing.T) {
|
||||
alice := test.NewUser(t)
|
||||
aliceLocalpart, serverName, err := gomatrixserverlib.SplitID('@', alice.ID)
|
||||
|
@ -100,13 +108,14 @@ func TestNotifyUserCountsAsync(t *testing.T) {
|
|||
}
|
||||
|
||||
// Insert a dummy event
|
||||
sender, err := spec.NewUserID(alice.ID, true)
|
||||
ev, err := synctypes.ToClientEvent(dummyEvent, synctypes.FormatAll, func(roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error) {
|
||||
return queryUserIDForSender(senderID)
|
||||
})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
sk := ""
|
||||
if err := db.InsertNotification(ctx, aliceLocalpart, serverName, dummyEvent.EventID(), 0, nil, &api.Notification{
|
||||
Event: synctypes.ToClientEvent(dummyEvent, synctypes.FormatAll, sender.String(), &sk, dummyEvent.Unsigned()),
|
||||
Event: *ev,
|
||||
}); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue