summaryrefslogtreecommitdiffstats
path: root/api4/post.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-06-28 10:28:17 -0400
committerChristopher Speller <crspeller@gmail.com>2017-06-28 07:28:17 -0700
commite527b6bbe4335f685528d305f8700d555420cf8e (patch)
treeb6623025c365e09bf2bbef69fd1ca60976b9da69 /api4/post.go
parent3e9b5c277653cef27b30f31c1db090777c22ed9d (diff)
downloadchat-e527b6bbe4335f685528d305f8700d555420cf8e.tar.gz
chat-e527b6bbe4335f685528d305f8700d555420cf8e.tar.bz2
chat-e527b6bbe4335f685528d305f8700d555420cf8e.zip
PLT-6931 Properly parse request body in post search (#6768)
* Properly parse request body in post search * Update driver to use correct body
Diffstat (limited to 'api4/post.go')
-rw-r--r--api4/post.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/api4/post.go b/api4/post.go
index 65a508df7..3d1077358 100644
--- a/api4/post.go
+++ b/api4/post.go
@@ -277,18 +277,14 @@ func searchPosts(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- props := model.MapFromJson(r.Body)
- terms := props["terms"]
-
- if len(terms) == 0 {
+ props := model.StringInterfaceFromJson(r.Body)
+ terms, ok := props["terms"].(string)
+ if !ok || len(terms) == 0 {
c.SetInvalidParam("terms")
return
}
- isOrSearch := false
- if val, ok := props["is_or_search"]; ok && val != "" {
- isOrSearch, _ = strconv.ParseBool(val)
- }
+ isOrSearch, _ := props["is_or_search"].(bool)
posts, err := app.SearchPostsInTeam(terms, c.Session.UserId, c.Params.TeamId, isOrSearch)
if err != nil {