diff options
author | devonh <devon.dmytro@gmail.com> | 2023-09-15 14:39:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-15 14:39:06 +0000 |
commit | 8245b24100b0afaa046bb3fe52f0994f906c8ab1 (patch) | |
tree | f8d65fd4c27e208e5829f5ca0f66d79c639fabdb /clientapi | |
parent | 058081e68e4e23400645c6206cedddba8a31507e (diff) |
Update gmsl to use new validated RoomID on PDUs (#3200)
GMSL returns a `spec.RoomID` when calling `PDU.RoomID()`
Diffstat (limited to 'clientapi')
-rw-r--r-- | clientapi/routing/redaction.go | 2 | ||||
-rw-r--r-- | clientapi/routing/sendevent.go | 2 | ||||
-rw-r--r-- | clientapi/routing/state.go | 9 |
3 files changed, 4 insertions, 9 deletions
diff --git a/clientapi/routing/redaction.go b/clientapi/routing/redaction.go index 230c96d2..aa579db6 100644 --- a/clientapi/routing/redaction.go +++ b/clientapi/routing/redaction.go @@ -98,7 +98,7 @@ func SendRedaction( JSON: spec.NotFound("unknown event ID"), // TODO: is it ok to leak existence? } } - if ev.RoomID() != roomID { + if ev.RoomID().String() != roomID { return util.JSONResponse{ Code: 400, JSON: spec.NotFound("cannot redact event in another room"), diff --git a/clientapi/routing/sendevent.go b/clientapi/routing/sendevent.go index f81e9c1e..fc9c05ba 100644 --- a/clientapi/routing/sendevent.go +++ b/clientapi/routing/sendevent.go @@ -437,7 +437,7 @@ func generateSendEvent( JSON: spec.BadJSON("Cannot unmarshal the event content."), } } - if content["replacement_room"] == e.RoomID() { + if content["replacement_room"] == e.RoomID().String() { return nil, &util.JSONResponse{ Code: http.StatusBadRequest, JSON: spec.InvalidParam("Cannot send tombstone event that points to the same room."), diff --git a/clientapi/routing/state.go b/clientapi/routing/state.go index d7f0b40f..6f363349 100644 --- a/clientapi/routing/state.go +++ b/clientapi/routing/state.go @@ -173,19 +173,14 @@ func OnIncomingStateRequest(ctx context.Context, device *userapi.Device, rsAPI a } for _, ev := range stateAfterRes.StateEvents { sender := spec.UserID{} - evRoomID, err := spec.NewRoomID(ev.RoomID()) - if err != nil { - util.GetLogger(ctx).WithError(err).Error("Event roomID is invalid") - continue - } - userID, err := rsAPI.QueryUserIDForSender(ctx, *evRoomID, ev.SenderID()) + 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, *evRoomID, spec.SenderID(*ev.StateKey())) + skUserID, err := rsAPI.QueryUserIDForSender(ctx, ev.RoomID(), spec.SenderID(*ev.StateKey())) if err == nil && skUserID != nil { skString := skUserID.String() sk = &skString |