Adds elasticsearch to the user and channel autocompletion functions (#10354)
* Adds elasticsearch to the user and channel autocompletion functions * Implement channel store GetChannelsByIds test * Style changes and govet fixes * Add gofmt fixes * Extract default channel search limit to a const * Add StringSliceDiff function to the utils package * Honor USER_SEARCH_MAX_LIMIT on the user autocomplete api handler * Change the elasticsearch development image
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5dae08761c
Коммит
44887a0272
@@ -52,6 +52,22 @@ func RemoveDuplicatesFromStringArray(arr []string) []string {
|
||||
return result
|
||||
}
|
||||
|
||||
func StringSliceDiff(a, b []string) []string {
|
||||
m := make(map[string]bool)
|
||||
result := []string{}
|
||||
|
||||
for _, item := range b {
|
||||
m[item] = true
|
||||
}
|
||||
|
||||
for _, item := range a {
|
||||
if !m[item] {
|
||||
result = append(result, item)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func GetIpAddress(r *http.Request) string {
|
||||
address := ""
|
||||
|
||||
|
||||
@@ -48,6 +48,14 @@ func TestRemoveDuplicatesFromStringArray(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringSliceDiff(t *testing.T) {
|
||||
a := []string{"one", "two", "three", "four", "five", "six"}
|
||||
b := []string{"two", "seven", "four", "six"}
|
||||
expected := []string{"one", "three", "five"}
|
||||
|
||||
assert.Equal(t, StringSliceDiff(a, b), expected)
|
||||
}
|
||||
|
||||
func TestGetIpAddress(t *testing.T) {
|
||||
// Test with a single IP in the X-Forwarded-For
|
||||
httpRequest1 := http.Request{
|
||||
|
||||
Ссылка в новой задаче
Block a user