summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/config.json1
-rw-r--r--i18n/en.json4
-rw-r--r--model/config.go6
-rw-r--r--model/search_params.go10
-rw-r--r--store/sql_post_store.go12
5 files changed, 33 insertions, 0 deletions
diff --git a/config/config.json b/config/config.json
index d1d3f9ae2..c8a52bd86 100644
--- a/config/config.json
+++ b/config/config.json
@@ -41,6 +41,7 @@
"AllowEditPost": "always",
"PostEditTimeLimit": 300,
"TimeBetweenUserTypingUpdatesMilliseconds": 5000,
+ "EnablePostSearch": true,
"EnableUserTypingMessages": true,
"ClusterLogTimeoutMilliseconds": 2000
},
diff --git a/i18n/en.json b/i18n/en.json
index d289877e0..75954a6c9 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -5204,6 +5204,10 @@
"translation": "Query error searching posts: %v"
},
{
+ "id": "store.sql_post.search.disabled",
+ "translation": "Searching has been disabled on this server. Please contact your System Administrator."
+ },
+ {
"id": "store.sql_post.update.app_error",
"translation": "We couldn't update the Post"
},
diff --git a/model/config.go b/model/config.go
index 90302bfec..206f5d70e 100644
--- a/model/config.go
+++ b/model/config.go
@@ -151,6 +151,7 @@ type ServiceSettings struct {
AllowEditPost *string
PostEditTimeLimit *int
TimeBetweenUserTypingUpdatesMilliseconds *int64
+ EnablePostSearch *bool
EnableUserTypingMessages *bool
ClusterLogTimeoutMilliseconds *int
}
@@ -1148,6 +1149,11 @@ func (o *Config) SetDefaults() {
*o.ServiceSettings.TimeBetweenUserTypingUpdatesMilliseconds = 5000
}
+ if o.ServiceSettings.EnablePostSearch == nil {
+ o.ServiceSettings.EnablePostSearch = new(bool)
+ *o.ServiceSettings.EnablePostSearch = true
+ }
+
if o.ServiceSettings.EnableUserTypingMessages == nil {
o.ServiceSettings.EnableUserTypingMessages = new(bool)
*o.ServiceSettings.EnableUserTypingMessages = true
diff --git a/model/search_params.go b/model/search_params.go
index 802ec1be8..070ac6d24 100644
--- a/model/search_params.go
+++ b/model/search_params.go
@@ -4,6 +4,7 @@
package model
import (
+ "encoding/json"
"regexp"
"strings"
)
@@ -19,6 +20,15 @@ type SearchParams struct {
OrTerms bool
}
+func (o *SearchParams) ToJson() string {
+ b, err := json.Marshal(o)
+ if err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
var searchFlags = [...]string{"from", "channel", "in"}
func splitWordsNoQuotes(text string) []string {
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index 5d8a7cfdc..9d852abff 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -908,6 +908,17 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
go func() {
result := StoreResult{}
+ if !*utils.Cfg.ServiceSettings.EnablePostSearch {
+ list := &model.PostList{}
+ list.MakeNonNil()
+ result.Data = list
+
+ result.Err = model.NewLocAppError("SqlPostStore.Search", "store.sql_post.search.disabled", nil, fmt.Sprintf("teamId=%v userId=%v params=%v", teamId, userId, params.ToJson()))
+ storeChannel <- result
+ close(storeChannel)
+ return
+ }
+
queryParams := map[string]interface{}{
"TeamId": teamId,
"UserId": userId,
@@ -919,6 +930,7 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
if terms == "" && len(params.InChannels) == 0 && len(params.FromUsers) == 0 {
result.Data = []*model.Post{}
storeChannel <- result
+ close(storeChannel)
return
}