summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authornickago <ngonella@calpoly.edu>2015-06-30 11:56:55 -0700
committernickago <ngonella@calpoly.edu>2015-06-30 11:57:57 -0700
commitbcc31b714b19ff3817c96c801028e23ace8cc55b (patch)
tree9ca11d12039146bec180fd5a0c1ac2c4974da5e1 /store
parent7a7be75e742603d06927a488b136e1ed4432aac2 (diff)
downloadchat-bcc31b714b19ff3817c96c801028e23ace8cc55b.tar.gz
chat-bcc31b714b19ff3817c96c801028e23ace8cc55b.tar.bz2
chat-bcc31b714b19ff3817c96c801028e23ace8cc55b.zip
Added the ability to have hashtags with dashes in them
Diffstat (limited to 'store')
-rw-r--r--store/sql_post_store.go16
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)
}