diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-05-25 14:31:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-25 14:31:07 +0100 |
commit | ac4d0072cf5507d7de1504d16aa5c4ca8537eb26 (patch) | |
tree | 558e4eb8f822a6f79516e6de071b258a2a4c92f1 | |
parent | 9ce3898d03445df97e5dba3701628100ef8b3051 (diff) |
Fix using the remote provided event from `/send_join` (#2490)
-rw-r--r-- | federationapi/internal/perform.go | 12 | ||||
-rw-r--r-- | federationapi/routing/join.go | 2 | ||||
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 4 |
4 files changed, 12 insertions, 8 deletions
diff --git a/federationapi/internal/perform.go b/federationapi/internal/perform.go index 970a6465..9100c8f1 100644 --- a/federationapi/internal/perform.go +++ b/federationapi/internal/perform.go @@ -213,10 +213,14 @@ func (r *FederationInternalAPI) performJoinUsingServer( // If the remote server returned an event in the "event" key of // the send_join request then we should use that instead. It may // contain signatures that we don't know about. - if respSendJoin.Event != nil && isWellFormedMembershipEvent( - respSendJoin.Event, roomID, userID, r.cfg.Matrix.ServerName, - ) { - event = respSendJoin.Event + if len(respSendJoin.Event) > 0 { + var remoteEvent *gomatrixserverlib.Event + remoteEvent, err = respSendJoin.Event.UntrustedEvent(respMakeJoin.RoomVersion) + if err == nil && isWellFormedMembershipEvent( + remoteEvent, roomID, userID, r.cfg.Matrix.ServerName, + ) { + event = remoteEvent + } } // Sanity-check the join response to ensure that it has a create diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go index 9f8d9410..abf9c094 100644 --- a/federationapi/routing/join.go +++ b/federationapi/routing/join.go @@ -403,7 +403,7 @@ func SendJoin( StateEvents: gomatrixserverlib.NewEventJSONsFromHeaderedEvents(stateAndAuthChainResponse.StateEvents), AuthEvents: gomatrixserverlib.NewEventJSONsFromHeaderedEvents(stateAndAuthChainResponse.AuthChainEvents), Origin: cfg.Matrix.ServerName, - Event: &signed, + Event: signed.JSON(), }, } } @@ -30,7 +30,7 @@ require ( github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91 github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16 - github.com/matrix-org/gomatrixserverlib v0.0.0-20220524100759-f98e737f8f9c + github.com/matrix-org/gomatrixserverlib v0.0.0-20220525125811-a75fa15a03a0 github.com/matrix-org/pinecone v0.0.0-20220408153826-2999ea29ed48 github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 github.com/mattn/go-sqlite3 v1.14.10 @@ -795,8 +795,8 @@ github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91/go.mod h1 github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0= github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16 h1:ZtO5uywdd5dLDCud4r0r55eP4j9FuUNpl60Gmntcop4= github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s= -github.com/matrix-org/gomatrixserverlib v0.0.0-20220524100759-f98e737f8f9c h1:J9krMtVgo4mV/G+mRA1u3GL6nNxdNnuPcs891uIQGic= -github.com/matrix-org/gomatrixserverlib v0.0.0-20220524100759-f98e737f8f9c/go.mod h1:V5eO8rn/C3rcxig37A/BCeKerLFS+9Avg/77FIeTZ48= +github.com/matrix-org/gomatrixserverlib v0.0.0-20220525125811-a75fa15a03a0 h1:wmxJJA5dczakTi7UsU/MWuWJY3gmC6RWzTN2S484tHo= +github.com/matrix-org/gomatrixserverlib v0.0.0-20220525125811-a75fa15a03a0/go.mod h1:V5eO8rn/C3rcxig37A/BCeKerLFS+9Avg/77FIeTZ48= github.com/matrix-org/pinecone v0.0.0-20220408153826-2999ea29ed48 h1:W0sjjC6yjskHX4mb0nk3p0fXAlbU5bAFUFeEtlrPASE= github.com/matrix-org/pinecone v0.0.0-20220408153826-2999ea29ed48/go.mod h1:ulJzsVOTssIVp1j/m5eI//4VpAGDkMt5NrRuAVX7wpc= github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U= |