From b7c900e0bbdea476e3afd605cb1283d8d1adc426 Mon Sep 17 00:00:00 2001 From: Sean Enck Date: Mon, 9 Jul 2018 19:53:52 -0400 Subject: [PATCH] Read receipt resp/req/client functions which resolves #51 --- client.go | 9 +++++++++ requests.go | 4 ++++ responses.go | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/client.go b/client.go index 7725ac3..bd9aad8 100644 --- a/client.go +++ b/client.go @@ -493,6 +493,15 @@ func (cli *Client) SendNotice(roomID, text string) (*RespSendEvent, error) { TextMessage{"m.notice", text}) } +// Receipt updates the marker for the given receipt type to the event ID specified. +// See https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid +func (cli *Client) Receipt(roomID, receiptType, eventID string, req *ReqReceipt) (resp *RespReceipt, err error) { + urlPath := cli.BuildURL("rooms", roomID, "receipt", receiptType, eventID) + _, err = cli.MakeRequest("POST", urlPath, req, nil) + return +} + + // 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 := txnID() diff --git a/requests.go b/requests.go index af99a22..1fe6257 100644 --- a/requests.go +++ b/requests.go @@ -76,3 +76,7 @@ type ReqTyping struct { Typing bool `json:"typing"` Timeout int64 `json:"timeout"` } + +// ReqReceipt is the JSON request for https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid +type ReqReceipt struct { +} diff --git a/responses.go b/responses.go index fe0eeb3..0483fec 100644 --- a/responses.go +++ b/responses.go @@ -174,3 +174,7 @@ type RespTurnServer struct { TTL int `json:"ttl"` URIs []string `json:"uris"` } + +// RespReceipt is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid +type RespReceipt struct { +}