Fix #632 and send spec-compliant transactions to the AS (#1091)

main
Kegsay 2020-06-04 11:17:37 +01:00 committed by GitHub
parent feb32ba365
commit d4f9a4bb97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"math" "math"
"net/http" "net/http"
"net/url"
"time" "time"
"github.com/matrix-org/dendrite/appservice/storage" "github.com/matrix-org/dendrite/appservice/storage"
@ -207,9 +208,15 @@ func send(
txnID int, txnID int,
transaction []byte, transaction []byte,
) error { ) error {
// POST a transaction to our AS // PUT a transaction to our AS
address := fmt.Sprintf("%s/transactions/%d", appservice.URL, txnID) // https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-app-v1-transactions-txnid
resp, err := client.Post(address, "application/json", bytes.NewBuffer(transaction)) 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 { if err != nil {
return err return err
} }