Added server parsing of wildcards

Этот коммит содержится в:
nickago
2015-08-13 15:34:56 -07:00
родитель d3093028cf
Коммит 72fc15ddf3

Просмотреть файл

@@ -5,9 +5,12 @@ package store
import ( import (
"fmt" "fmt"
"regexp"
"strconv"
"strings"
"github.com/mattermost/platform/model" "github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils" "github.com/mattermost/platform/utils"
"strings"
) )
type SqlPostStore struct { type SqlPostStore struct {
@@ -416,6 +419,12 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht
// cannot escape it so we replace it. // cannot escape it so we replace it.
terms = strings.Replace(terms, "@", " ", -1) 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 var posts []*model.Post
if utils.Cfg.SqlSettings.DriverName == "postgres" { if utils.Cfg.SqlSettings.DriverName == "postgres" {