From 55341ef3cf84b03296c083c350f70d3a81180f07 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 15 Sep 2022 14:15:31 -0700 Subject: [PATCH] Refresh dendrite subtree - pull changes for appservice bug (#457) Co-authored-by: Tak Wai Wong --- .gitignore | 1 + appservice/consumers/roomserver.go | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 820120c95..cbbf5981a 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ _testmain.go # Default configuration file dendrite.yaml +zion-appservice.yaml # Database files *.db diff --git a/appservice/consumers/roomserver.go b/appservice/consumers/roomserver.go index a4bcfa7d9..381440f0f 100644 --- a/appservice/consumers/roomserver.go +++ b/appservice/consumers/roomserver.go @@ -173,13 +173,14 @@ func (s *OutputRoomEventConsumer) sendEvents( return err } - // TODO: We should probably be more intelligent and pick something not - // in the control of the event. A NATS timestamp header or something maybe. - txnID := events[0].Event.OriginServerTS() + // If the number of items in the array is different, + // then this should be treated as a different transaction. Incorporate the length + // of events into the transaction ID. + txnID := fmt.Sprintf("%d_%d", events[0].Event.OriginServerTS(), len(transaction)) // Send the transaction to the appservice. // https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-app-v1-transactions-txnid - address := fmt.Sprintf("%s/transactions/%d?access_token=%s", state.URL, txnID, url.QueryEscape(state.HSToken)) + address := fmt.Sprintf("%s/transactions/%s?access_token=%s", state.URL, txnID, url.QueryEscape(state.HSToken)) req, err := http.NewRequestWithContext(ctx, "PUT", address, bytes.NewBuffer(transaction)) if err != nil { return err