summaryrefslogtreecommitdiffstats
path: root/api/post.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-05-09 12:00:08 -0400
committerCorey Hulen <corey@hulen.com>2016-05-09 09:00:08 -0700
commit07126101d379b900724c7c5cfc82070b42c235d6 (patch)
tree80b2485b61eb1684cd6127473267af206c3ab1c2 /api/post.go
parent9e07f4b021b28a3e301359a48cf950298f3e552e (diff)
downloadchat-07126101d379b900724c7c5cfc82070b42c235d6.tar.gz
chat-07126101d379b900724c7c5cfc82070b42c235d6.tar.bz2
chat-07126101d379b900724c7c5cfc82070b42c235d6.zip
Recent mention searches now OR terms instead of AND (#2931)
Diffstat (limited to 'api/post.go')
-rw-r--r--api/post.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/api/post.go b/api/post.go
index a33b6ebf0..ac499e615 100644
--- a/api/post.go
+++ b/api/post.go
@@ -25,7 +25,7 @@ import (
func InitPost() {
l4g.Debug(utils.T("api.post.init.debug"))
- BaseRoutes.NeedTeam.Handle("/posts/search", ApiUserRequired(searchPosts)).Methods("GET")
+ BaseRoutes.NeedTeam.Handle("/posts/search", ApiUserRequired(searchPosts)).Methods("POST")
BaseRoutes.NeedTeam.Handle("/posts/{post_id}", ApiUserRequired(getPostById)).Methods("GET")
BaseRoutes.NeedTeam.Handle("/pltmp/{post_id}", ApiUserRequired(getPermalinkTmp)).Methods("GET")
@@ -1289,17 +1289,24 @@ func getPostsBeforeOrAfter(c *Context, w http.ResponseWriter, r *http.Request, b
}
func searchPosts(c *Context, w http.ResponseWriter, r *http.Request) {
- terms := r.FormValue("terms")
+ props := model.StringInterfaceFromJson(r.Body)
+ terms := props["terms"].(string)
if len(terms) == 0 {
c.SetInvalidParam("search", "terms")
return
}
+ isOrSearch := false
+ if val, ok := props["is_or_search"]; ok && val != nil {
+ isOrSearch = val.(bool)
+ }
+
paramsList := model.ParseSearchParams(terms)
channels := []store.StoreChannel{}
for _, params := range paramsList {
+ params.OrTerms = isOrSearch
// don't allow users to search for everything
if params.Terms != "*" {
channels = append(channels, Srv.Store.Post().Search(c.TeamId, c.Session.UserId, params))