summaryrefslogtreecommitdiffstats
path: root/store/sql_post_store.go
diff options
context:
space:
mode:
authornickago <ngonella@calpoly.edu>2015-08-13 15:34:56 -0700
committernickago <ngonella@calpoly.edu>2015-08-27 08:57:07 -0700
commit72fc15ddf370acd836736ff3e3cd33c24c126a17 (patch)
treee35ab78fc911f4628b82c9339379b4472e9c6de0 /store/sql_post_store.go
parentd3093028cff337ede3747c6f0908eda432c3cb88 (diff)
downloadchat-72fc15ddf370acd836736ff3e3cd33c24c126a17.tar.gz
chat-72fc15ddf370acd836736ff3e3cd33c24c126a17.tar.bz2
chat-72fc15ddf370acd836736ff3e3cd33c24c126a17.zip
Added server parsing of wildcards
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r--store/sql_post_store.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index 4ea28507b..fdff27b82 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -5,9 +5,12 @@ package store
import (
"fmt"
+ "regexp"
+ "strconv"
+ "strings"
+
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
- "strings"
)
type SqlPostStore struct {
@@ -361,7 +364,7 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S
var posts []*model.Post
_, err := s.GetReplica().Select(&posts,
- `SELECT
+ `SELECT
q2.*
FROM
Posts q2
@@ -369,7 +372,7 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S
(SELECT DISTINCT
q3.RootId
FROM
- (SELECT
+ (SELECT
RootId
FROM
Posts
@@ -416,6 +419,12 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht
// cannot escape it so we replace it.
terms = strings.Replace(terms, "@", " ", -1)
+ // Parse text for wildcards
+ if wildcard, err := regexp.Compile("\\*($| )"); err == nil {
+ terms = wildcard.ReplaceAllLiteralString(terms, ":* ")
+ terms = strings.Replace(terms, " ", " ", -1)
+ }
+
var posts []*model.Post
if utils.Cfg.SqlSettings.DriverName == "postgres" {