From d4f9a4bb97c0c66963d7fd9c1395614a2198112e Mon Sep 17 00:00:00 2001 From: Kegsay Date: Thu, 4 Jun 2020 11:17:37 +0100 Subject: [PATCH] Fix #632 and send spec-compliant transactions to the AS (#1091) --- appservice/workers/transaction_scheduler.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/appservice/workers/transaction_scheduler.go b/appservice/workers/transaction_scheduler.go index 20805619..63ec58aa 100644 --- a/appservice/workers/transaction_scheduler.go +++ b/appservice/workers/transaction_scheduler.go @@ -21,6 +21,7 @@ import ( "fmt" "math" "net/http" + "net/url" "time" "github.com/matrix-org/dendrite/appservice/storage" @@ -207,9 +208,15 @@ func send( txnID int, transaction []byte, ) error { - // POST a transaction to our AS - address := fmt.Sprintf("%s/transactions/%d", appservice.URL, txnID) - resp, err := client.Post(address, "application/json", bytes.NewBuffer(transaction)) + // PUT a transaction to our AS + // 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", appservice.URL, txnID, url.QueryEscape(appservice.HSToken)) + req, err := http.NewRequest("PUT", address, bytes.NewBuffer(transaction)) + if err != nil { + return err + } + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) if err != nil { return err }