Merge pull request #50 from mautrix/allow-extra-fields-on-redactions

client.RedactEvent: allow arbitrary fields in redaction request
This commit is contained in:
Sumner Evans 2021-12-15 10:33:55 -07:00 committed by GitHub
commit 74c736365e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -975,6 +975,12 @@ func (cli *Client) RedactEvent(roomID id.RoomID, eventID id.EventID, extra ...Re
if len(extra) > 0 {
req = extra[0]
}
if req.Extra == nil {
req.Extra = make(map[string]interface{})
}
if len(req.Reason) > 0 {
req.Extra["reason"] = req.Reason
}
var txnID string
if len(req.TxnID) > 0 {
txnID = req.TxnID
@ -982,7 +988,7 @@ func (cli *Client) RedactEvent(roomID id.RoomID, eventID id.EventID, extra ...Re
txnID = cli.TxnID()
}
urlPath := cli.BuildURL("rooms", roomID, "redact", eventID, txnID)
_, err = cli.MakeRequest("PUT", urlPath, req, &resp)
_, err = cli.MakeRequest("PUT", urlPath, req.Extra, &resp)
return
}

View file

@ -105,8 +105,9 @@ type ReqCreateRoom struct {
// ReqRedact is the JSON request for http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid
type ReqRedact struct {
Reason string `json:"reason,omitempty"`
TxnID string `json:"-"`
Reason string
TxnID string
Extra map[string]interface{}
}
type ReqMembers struct {