aboutsummaryrefslogtreecommitdiff
path: root/syncapi/synctypes/clientevent.go
diff options
context:
space:
mode:
Diffstat (limited to 'syncapi/synctypes/clientevent.go')
-rw-r--r--syncapi/synctypes/clientevent.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/syncapi/synctypes/clientevent.go b/syncapi/synctypes/clientevent.go
index 433be39f..6f03d9ff 100644
--- a/syncapi/synctypes/clientevent.go
+++ b/syncapi/synctypes/clientevent.go
@@ -52,14 +52,18 @@ func ToClientEvents(serverEvs []gomatrixserverlib.PDU, format ClientEventFormat,
continue // TODO: shouldn't happen?
}
sender := spec.UserID{}
- userID, err := userIDForSender(se.RoomID(), se.SenderID())
+ validRoomID, err := spec.NewRoomID(se.RoomID())
+ if err != nil {
+ continue
+ }
+ userID, err := userIDForSender(*validRoomID, se.SenderID())
if err == nil && userID != nil {
sender = *userID
}
sk := se.StateKey()
if sk != nil && *sk != "" {
- skUserID, err := userIDForSender(se.RoomID(), spec.SenderID(*sk))
+ skUserID, err := userIDForSender(*validRoomID, spec.SenderID(*sk))
if err == nil && skUserID != nil {
skString := skUserID.String()
sk = &skString
@@ -95,14 +99,18 @@ func ToClientEvent(se gomatrixserverlib.PDU, format ClientEventFormat, sender sp
// It provides default logic for event.SenderID & event.StateKey -> userID conversions.
func ToClientEventDefault(userIDQuery spec.UserIDForSender, event gomatrixserverlib.PDU) ClientEvent {
sender := spec.UserID{}
- userID, err := userIDQuery(event.RoomID(), event.SenderID())
+ validRoomID, err := spec.NewRoomID(event.RoomID())
+ if err != nil {
+ return ClientEvent{}
+ }
+ userID, err := userIDQuery(*validRoomID, event.SenderID())
if err == nil && userID != nil {
sender = *userID
}
sk := event.StateKey()
if sk != nil && *sk != "" {
- skUserID, err := userIDQuery(event.RoomID(), spec.SenderID(*event.StateKey()))
+ skUserID, err := userIDQuery(*validRoomID, spec.SenderID(*event.StateKey()))
if err == nil && skUserID != nil {
skString := skUserID.String()
sk = &skString