From 30c70355223452057c8528028e63afb90d6610af Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 5 Jan 2017 14:33:38 +0000 Subject: [PATCH] Add /redact endpoint --- client.go | 8 ++++++++ requests.go | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/client.go b/client.go index c3a4d4e..71d50c2 100644 --- a/client.go +++ b/client.go @@ -393,6 +393,14 @@ func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error) { TextMessage{"m.text", text}) } +// RedactEvent redacts the given event. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid +func (cli *Client) RedactEvent(roomID, eventID string, req *ReqRedact) (resp *RespSendEvent, err error) { + txnID := "go" + strconv.FormatInt(time.Now().UnixNano(), 10) + urlPath := cli.BuildURL("rooms", roomID, "redact", eventID, txnID) + _, err = cli.MakeRequest("PUT", urlPath, req, &resp) + return +} + // CreateRoom creates a new Matrix room. See https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom // resp, err := cli.CreateRoom(&gomatrix.ReqCreateRoom{ // Preset: "public_chat", diff --git a/requests.go b/requests.go index d26cf9d..a2a960e 100644 --- a/requests.go +++ b/requests.go @@ -36,6 +36,11 @@ type ReqCreateRoom struct { IsDirect bool `json:"is_direct,omitempty"` } +// 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"` +} + // ReqInvite3PID is the JSON request for https://matrix.org/docs/spec/client_server/r0.2.0.html#id57 // It is also a JSON object used in https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom type ReqInvite3PID struct {