mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Merge pull request #50 from mautrix/allow-extra-fields-on-redactions
client.RedactEvent: allow arbitrary fields in redaction request
This commit is contained in:
commit
74c736365e
2 changed files with 10 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue