diff options
author | Corey Hulen <corey@hulen.com> | 2015-06-30 19:46:25 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-06-30 19:46:25 -0800 |
commit | 75c19380776e9ebf30345a922bd3a0e2df0711f4 (patch) | |
tree | c4d2128772fb279b5d2c2641162e6304a98a163a /store/sql_post_store.go | |
parent | 1200f764842ec11557b686ca9226b357ff5b0c93 (diff) | |
parent | bcc31b714b19ff3817c96c801028e23ace8cc55b (diff) | |
download | chat-75c19380776e9ebf30345a922bd3a0e2df0711f4.tar.gz chat-75c19380776e9ebf30345a922bd3a0e2df0711f4.tar.bz2 chat-75c19380776e9ebf30345a922bd3a0e2df0711f4.zip |
Merge pull request #110 from nickago/MM-1430
MM-1430 Added the ability to have hashtags with dashes in them
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r-- | store/sql_post_store.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go index 0ceebc02f..01900023f 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -356,9 +356,14 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht go func() { result := StoreResult{} + termMap := map[string]bool{} + searchType := "Message" if isHashtagSearch { searchType = "Hashtags" + for _,term := range strings.Split(terms, " ") { + termMap[term] = true; + } } // @ has a speical meaning in INNODB FULLTEXT indexes and @@ -394,6 +399,17 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht list := &model.PostList{Order: make([]string, 0, len(posts))} for _, p := range posts { + if searchType == "Hashtags" { + exactMatch := false + for _, tag := range strings.Split(p.Hashtags, " ") { + if termMap[tag] { + exactMatch = true + } + } + if !exactMatch { + continue + } + } list.AddPost(p) list.AddOrder(p.Id) } |