Skip to content

Commit

Permalink
Temporary fix for appservice txnid (Dendrite issue matrix-org#2718) (#29
Browse files Browse the repository at this point in the history
)

* temporary fix for dendrite regression matrix-org#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 <tak@hntlabs.com>
  • Loading branch information
tak-hntlabs and tak-hntlabs committed Sep 15, 2022
1 parent 6ffe814 commit 333a5c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -53,6 +53,7 @@ _testmain.go

# Default configuration file
dendrite.yaml
zion-appservice.yaml

# Database files
*.db
Expand Down
9 changes: 5 additions & 4 deletions appservice/consumers/roomserver.go
Expand Up @@ -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
Expand Down

0 comments on commit 333a5c7

Please sign in to comment.