Adding the ability to disable full text search queries for master (#6102)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
7e29dc65aa
Коммит
3207886514
@@ -41,6 +41,7 @@
|
|||||||
"AllowEditPost": "always",
|
"AllowEditPost": "always",
|
||||||
"PostEditTimeLimit": 300,
|
"PostEditTimeLimit": 300,
|
||||||
"TimeBetweenUserTypingUpdatesMilliseconds": 5000,
|
"TimeBetweenUserTypingUpdatesMilliseconds": 5000,
|
||||||
|
"EnablePostSearch": true,
|
||||||
"EnableUserTypingMessages": true,
|
"EnableUserTypingMessages": true,
|
||||||
"ClusterLogTimeoutMilliseconds": 2000
|
"ClusterLogTimeoutMilliseconds": 2000
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5203,6 +5203,10 @@
|
|||||||
"id": "store.sql_post.search.warn",
|
"id": "store.sql_post.search.warn",
|
||||||
"translation": "Query error searching posts: %v"
|
"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",
|
"id": "store.sql_post.update.app_error",
|
||||||
"translation": "We couldn't update the Post"
|
"translation": "We couldn't update the Post"
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ type ServiceSettings struct {
|
|||||||
AllowEditPost *string
|
AllowEditPost *string
|
||||||
PostEditTimeLimit *int
|
PostEditTimeLimit *int
|
||||||
TimeBetweenUserTypingUpdatesMilliseconds *int64
|
TimeBetweenUserTypingUpdatesMilliseconds *int64
|
||||||
|
EnablePostSearch *bool
|
||||||
EnableUserTypingMessages *bool
|
EnableUserTypingMessages *bool
|
||||||
ClusterLogTimeoutMilliseconds *int
|
ClusterLogTimeoutMilliseconds *int
|
||||||
}
|
}
|
||||||
@@ -1148,6 +1149,11 @@ func (o *Config) SetDefaults() {
|
|||||||
*o.ServiceSettings.TimeBetweenUserTypingUpdatesMilliseconds = 5000
|
*o.ServiceSettings.TimeBetweenUserTypingUpdatesMilliseconds = 5000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.ServiceSettings.EnablePostSearch == nil {
|
||||||
|
o.ServiceSettings.EnablePostSearch = new(bool)
|
||||||
|
*o.ServiceSettings.EnablePostSearch = true
|
||||||
|
}
|
||||||
|
|
||||||
if o.ServiceSettings.EnableUserTypingMessages == nil {
|
if o.ServiceSettings.EnableUserTypingMessages == nil {
|
||||||
o.ServiceSettings.EnableUserTypingMessages = new(bool)
|
o.ServiceSettings.EnableUserTypingMessages = new(bool)
|
||||||
*o.ServiceSettings.EnableUserTypingMessages = true
|
*o.ServiceSettings.EnableUserTypingMessages = true
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -19,6 +20,15 @@ type SearchParams struct {
|
|||||||
OrTerms bool
|
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"}
|
var searchFlags = [...]string{"from", "channel", "in"}
|
||||||
|
|
||||||
func splitWordsNoQuotes(text string) []string {
|
func splitWordsNoQuotes(text string) []string {
|
||||||
|
|||||||
@@ -908,6 +908,17 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
|
|||||||
go func() {
|
go func() {
|
||||||
result := StoreResult{}
|
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{}{
|
queryParams := map[string]interface{}{
|
||||||
"TeamId": teamId,
|
"TeamId": teamId,
|
||||||
"UserId": userId,
|
"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 {
|
if terms == "" && len(params.InChannels) == 0 && len(params.FromUsers) == 0 {
|
||||||
result.Data = []*model.Post{}
|
result.Data = []*model.Post{}
|
||||||
storeChannel <- result
|
storeChannel <- result
|
||||||
|
close(storeChannel)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user