aboutsummaryrefslogtreecommitdiff
path: root/appservice/consumers/roomserver.go
diff options
context:
space:
mode:
Diffstat (limited to 'appservice/consumers/roomserver.go')
-rw-r--r--appservice/consumers/roomserver.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/appservice/consumers/roomserver.go b/appservice/consumers/roomserver.go
index b7fc1f69..b07b24fc 100644
--- a/appservice/consumers/roomserver.go
+++ b/appservice/consumers/roomserver.go
@@ -206,13 +206,21 @@ func (s *OutputRoomEventConsumer) sendEvents(
}
// 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/%s?access_token=%s", state.RequestUrl(), txnID, url.QueryEscape(state.HSToken))
+ // https://spec.matrix.org/v1.9/application-service-api/#pushing-events
+ path := "_matrix/app/v1/transactions"
+ if s.cfg.LegacyPaths {
+ path = "transactions"
+ }
+ address := fmt.Sprintf("%s/%s/%s", state.RequestUrl(), path, txnID)
+ if s.cfg.LegacyAuth {
+ address += "?access_token=" + url.QueryEscape(state.HSToken)
+ }
req, err := http.NewRequestWithContext(ctx, "PUT", address, bytes.NewBuffer(transaction))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
+ req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", state.HSToken))
resp, err := state.HTTPClient.Do(req)
if err != nil {
return state.backoffAndPause(err)