summaryrefslogtreecommitdiffstats
path: root/model/client4.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/client4.go')
-rw-r--r--model/client4.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index 833050561..6ace37dca 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -10,6 +10,7 @@ import (
"io/ioutil"
"mime/multipart"
"net/http"
+ "strconv"
"strings"
)
@@ -684,6 +685,16 @@ func (c *Client4) GetPost(postId string, etag string) (*Post, *Response) {
}
}
+// DeletePost deletes a post from the provided post id string.
+func (c *Client4) DeletePost(postId string) (bool, *Response) {
+ if r, err := c.DoApiDelete(c.GetPostRoute(postId)); err != nil {
+ return false, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return CheckStatusOK(r), BuildResponse(r)
+ }
+}
+
// GetPostThread gets a post with all the other posts in the same thread.
func (c *Client4) GetPostThread(postId string, etag string) (*PostList, *Response) {
if r, err := c.DoApiGet(c.GetPostRoute(postId)+"/thread", etag); err != nil {
@@ -705,6 +716,17 @@ func (c *Client4) GetPostsForChannel(channelId string, page, perPage int, etag s
}
}
+// SearchPosts returns any posts with matching terms string.
+func (c *Client4) SearchPosts(teamId string, terms string, isOrSearch bool) (*PostList, *Response) {
+ requestBody := map[string]string{"terms": terms, "is_or_search": strconv.FormatBool(isOrSearch)}
+ if r, err := c.DoApiPost(c.GetTeamRoute(teamId)+"/posts/search", MapToJson(requestBody)); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return PostListFromJson(r.Body), BuildResponse(r)
+ }
+}
+
// File Section
// UploadFile will upload a file to a channel, to be later attached to a post.