diff options
author | kegsay <kegan@matrix.org> | 2023-05-04 11:17:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 11:17:42 +0100 |
commit | 2b34f88fde6b3aa633c8f23ff424a5db4951efd3 (patch) | |
tree | bbf58904af8499f756fc1965f63a5ca359418c0a /federationapi/internal | |
parent | d5c11a3c86bf1eeb7ae6b1c243ec889432fcd881 (diff) |
Use ProtoEvent where needed instead of EventBuilder (#3075)
They are fundamentally different concepts, so should be represented as
such. Proto events are exchanged in /make_xxx calls over federation, and
made as "fledgling" events in /createRoom and general event sending.
*Building* events is a reasonably complex VERSION SPECIFIC process which
needs amongst other things, auth event providers, prev events, signing
keys, etc.
Requires https://github.com/matrix-org/gomatrixserverlib/pull/379
Diffstat (limited to 'federationapi/internal')
-rw-r--r-- | federationapi/internal/perform.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/federationapi/internal/perform.go b/federationapi/internal/perform.go index f55995ca..99943d86 100644 --- a/federationapi/internal/perform.go +++ b/federationapi/internal/perform.go @@ -439,7 +439,7 @@ func (r *FederationInternalAPI) PerformLeave( // Work out if we support the room version that has been supplied in // the make_leave response. - _, err = gomatrixserverlib.GetRoomVersion(respMakeLeave.RoomVersion) + verImpl, err := gomatrixserverlib.GetRoomVersion(respMakeLeave.RoomVersion) if err != nil { return err } @@ -451,27 +451,28 @@ func (r *FederationInternalAPI) PerformLeave( respMakeLeave.LeaveEvent.StateKey = &request.UserID respMakeLeave.LeaveEvent.RoomID = request.RoomID respMakeLeave.LeaveEvent.Redacts = "" + leaveEB := verImpl.NewEventBuilderFromProtoEvent(&respMakeLeave.LeaveEvent) + if respMakeLeave.LeaveEvent.Content == nil { content := map[string]interface{}{ "membership": "leave", } - if err = respMakeLeave.LeaveEvent.SetContent(content); err != nil { + if err = leaveEB.SetContent(content); err != nil { logrus.WithError(err).Warnf("respMakeLeave.LeaveEvent.SetContent failed") continue } } - if err = respMakeLeave.LeaveEvent.SetUnsigned(struct{}{}); err != nil { + if err = leaveEB.SetUnsigned(struct{}{}); err != nil { logrus.WithError(err).Warnf("respMakeLeave.LeaveEvent.SetUnsigned failed") continue } // Build the leave event. - event, err := respMakeLeave.LeaveEvent.Build( + event, err := leaveEB.Build( time.Now(), origin, r.cfg.Matrix.KeyID, r.cfg.Matrix.PrivateKey, - respMakeLeave.RoomVersion, ) if err != nil { logrus.WithError(err).Warnf("respMakeLeave.LeaveEvent.Build failed") |