Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Receipt client function #51

Open
seanenck opened this issue Jun 18, 2018 · 1 comment
Open

Receipt client function #51

seanenck opened this issue Jun 18, 2018 · 1 comment

Comments

@seanenck
Copy link

seanenck commented Jun 18, 2018

Any interest in adding a receipt client function to send receipts using the API endpoints

e.g.

diff --git a/client.go b/client.go
index 7725ac3..2819d8d 100644
--- a/client.go
+++ b/client.go
@@ -449,6 +449,13 @@ func (cli *Client) SendMessageEvent(roomID string, eventType string, contentJSON
        return
 }
 
+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
+}
+
+
 // SendStateEvent sends a state event into a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey
 // contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal.
 func (cli *Client) SendStateEvent(roomID, eventType, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error) {
diff --git a/requests.go b/requests.go
index af99a22..f044fff 100644
--- a/requests.go
+++ b/requests.go
@@ -76,3 +76,6 @@ type ReqTyping struct {
        Typing  bool  `json:"typing"`
        Timeout int64 `json:"timeout"`
 }
+
+type ReqReceipt struct {
+}
diff --git a/responses.go b/responses.go
index fe0eeb3..8539969 100644
--- a/responses.go
+++ b/responses.go
@@ -174,3 +174,6 @@ type RespTurnServer struct {
        TTL      int      `json:"ttl"`
        URIs     []string `json:"uris"`
 }
+
+type RespReceipt struct {
+}

Happy to cleanup and submit this as a PR if it seems reasonable

@kegsay
Copy link
Member

kegsay commented Apr 8, 2020

Very much so. However, longer term it's likely that I will end up doing what so many others do and autogen the structs using something like go-swagger. This means this client will be focussed on the core Matrix logic rather than tedious creation of req/res structs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants