From 07126101d379b900724c7c5cfc82070b42c235d6 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 9 May 2016 12:00:08 -0400 Subject: Recent mention searches now OR terms instead of AND (#2931) --- api/post.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'api/post.go') 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)) -- cgit v1.2.3-1-g7c22