From 417c7d3569151ddd54c1264a8241b611e58c2acd Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 2 Dec 2020 15:14:12 +0000 Subject: [PATCH] Send client events to appservices (#1603) * Send client events to appservices * FormatSync instead of FormatAll --- appservice/workers/transaction_scheduler.go | 8 ++++---- go.mod | 2 +- go.sum | 4 ++-- syncapi/types/types.go | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/appservice/workers/transaction_scheduler.go b/appservice/workers/transaction_scheduler.go index cc9907481..6e8e8f4a3 100644 --- a/appservice/workers/transaction_scheduler.go +++ b/appservice/workers/transaction_scheduler.go @@ -185,14 +185,14 @@ func createTransaction( } } - var ev []*gomatrixserverlib.Event - for _, e := range events { - ev = append(ev, e.Event) + var ev []*gomatrixserverlib.HeaderedEvent + for i := range events { + ev = append(ev, &events[i]) } // Create a transaction and store the events inside transaction := gomatrixserverlib.ApplicationServiceTransaction{ - Events: ev, + Events: gomatrixserverlib.HeaderedToClientEvents(ev, gomatrixserverlib.FormatAll), } transactionJSON, err = json.Marshal(transaction) diff --git a/go.mod b/go.mod index 42eeaf04e..d01c80860 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4 github.com/matrix-org/go-sqlite3-js v0.0.0-20200522092705-bc8506ccbcf3 github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd - github.com/matrix-org/gomatrixserverlib v0.0.0-20201116151724-6e7b24e4956c + github.com/matrix-org/gomatrixserverlib v0.0.0-20201202134418-2ba106a5bca3 github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91 github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 github.com/mattn/go-sqlite3 v1.14.2 diff --git a/go.sum b/go.sum index 1341894df..18715f86a 100644 --- a/go.sum +++ b/go.sum @@ -569,8 +569,8 @@ github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26 h1:Hr3zjRsq2bh github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0= github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd h1:xVrqJK3xHREMNjwjljkAUaadalWc0rRbmVuQatzmgwg= github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s= -github.com/matrix-org/gomatrixserverlib v0.0.0-20201116151724-6e7b24e4956c h1:iiloytJig9EmlKwuSulIbNvoPz1BFZ1QdyPWpuy85XM= -github.com/matrix-org/gomatrixserverlib v0.0.0-20201116151724-6e7b24e4956c/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU= +github.com/matrix-org/gomatrixserverlib v0.0.0-20201202134418-2ba106a5bca3 h1:+45Q/5FybBhHPMr10YdzJNFYO/6RRgkBcZbMzIRq5Ck= +github.com/matrix-org/gomatrixserverlib v0.0.0-20201202134418-2ba106a5bca3/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU= github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91 h1:HJ6U3S3ljJqNffYMcIeAncp5qT/i+ZMiJ2JC2F0aXP4= github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91/go.mod h1:sjyPyRxKM5uw1nD2cJ6O2OxI6GOqyVBfNXqKjBZTBZE= github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7 h1:ntrLa/8xVzeSs8vHFHK25k0C+NV74sYMJnNSg5NoSRo= diff --git a/syncapi/types/types.go b/syncapi/types/types.go index 91d33d4a6..36f30c20b 100644 --- a/syncapi/types/types.go +++ b/syncapi/types/types.go @@ -484,8 +484,7 @@ func NewInviteResponse(event *gomatrixserverlib.HeaderedEvent) *InviteResponse { // Then we'll see if we can create a partial of the invite event itself. // This is needed for clients to work out *who* sent the invite. - format, _ := event.RoomVersion.EventFormat() - inviteEvent := gomatrixserverlib.ToClientEvent(event.Unwrap(), format) + inviteEvent := gomatrixserverlib.ToClientEvent(event.Unwrap(), gomatrixserverlib.FormatSync) inviteEvent.Unsigned = nil if ev, err := json.Marshal(inviteEvent); err == nil { res.InviteState.Events = append(res.InviteState.Events, ev)