From 333a5c74c87111f44c5d2068d6ed651462d2d2b0 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 15 Sep 2022 13:49:05 -0700 Subject: [PATCH] Temporary fix for appservice txnid (Dendrite issue #2718) (#29) * temporary fix for dendrite regression #2718 * Change comment to match with dendrite main pr * renamed zion-registration.yaml to zion-appservice.yaml. Change gitignore to ignore this file. 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