summaryrefslogtreecommitdiffstats
path: root/model/client4.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-03 10:27:12 -0500
committerChristopher Speller <crspeller@gmail.com>2017-02-03 10:27:12 -0500
commit9312469ad54cf2ff268a44e478b584549f62e2c4 (patch)
tree6b29783b9341b54a16aca581c4878f3cdd7474d7 /model/client4.go
parentccb034382850b7e8ea924a4559e47ef44203155c (diff)
downloadchat-9312469ad54cf2ff268a44e478b584549f62e2c4.tar.gz
chat-9312469ad54cf2ff268a44e478b584549f62e2c4.tar.bz2
chat-9312469ad54cf2ff268a44e478b584549f62e2c4.zip
Implement POST /channels/direct endpoint for APIv4 (#5283)
Diffstat (limited to 'model/client4.go')
-rw-r--r--model/client4.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index fb314e26d..6ea0398d0 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -265,5 +265,17 @@ func (c *Client4) CreateChannel(channel *Channel) (*Channel, *Response) {
}
}
+// CreateDirectChannel creates a direct message channel based on the two user
+// ids provided.
+func (c *Client4) CreateDirectChannel(userId1, userId2 string) (*Channel, *Response) {
+ requestBody := []string{userId1, userId2}
+ if r, err := c.DoApiPost(c.GetChannelsRoute()+"/direct", ArrayToJson(requestBody)); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return ChannelFromJson(r.Body), BuildResponse(r)
+ }
+}
+
// Post Section
// to be filled in..