Fix user autocomplete for DMs and GMs (#6265)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
91f3e10854
Коммит
36a15925dc
34
api4/user.go
34
api4/user.go
@@ -468,25 +468,23 @@ func autocompleteUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY] = true
|
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(teamId) > 0 {
|
if len(channelId) > 0 {
|
||||||
if len(channelId) > 0 {
|
if !app.SessionHasPermissionToChannel(c.Session, channelId, model.PERMISSION_READ_CHANNEL) {
|
||||||
if !app.SessionHasPermissionToChannel(c.Session, channelId, model.PERMISSION_READ_CHANNEL) {
|
c.SetPermissionError(model.PERMISSION_READ_CHANNEL)
|
||||||
c.SetPermissionError(model.PERMISSION_READ_CHANNEL)
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result, _ := app.AutocompleteUsersInChannel(teamId, channelId, name, searchOptions, c.IsSystemAdmin())
|
|
||||||
autocomplete.Users = result.InChannel
|
|
||||||
autocomplete.OutOfChannel = result.OutOfChannel
|
|
||||||
} else {
|
|
||||||
if !app.SessionHasPermissionToTeam(c.Session, teamId, model.PERMISSION_VIEW_TEAM) {
|
|
||||||
c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result, _ := app.AutocompleteUsersInTeam(teamId, name, searchOptions, c.IsSystemAdmin())
|
|
||||||
autocomplete.Users = result.InTeam
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result, _ := app.AutocompleteUsersInChannel(teamId, channelId, name, searchOptions, c.IsSystemAdmin())
|
||||||
|
autocomplete.Users = result.InChannel
|
||||||
|
autocomplete.OutOfChannel = result.OutOfChannel
|
||||||
|
} else if len(teamId) > 0 {
|
||||||
|
if !app.SessionHasPermissionToTeam(c.Session, teamId, model.PERMISSION_VIEW_TEAM) {
|
||||||
|
c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, _ := app.AutocompleteUsersInTeam(teamId, name, searchOptions, c.IsSystemAdmin())
|
||||||
|
autocomplete.Users = result.InTeam
|
||||||
} else {
|
} else {
|
||||||
// No permission check required
|
// No permission check required
|
||||||
result, _ := app.SearchUsersInTeam("", name, searchOptions, c.IsSystemAdmin())
|
result, _ := app.SearchUsersInTeam("", name, searchOptions, c.IsSystemAdmin())
|
||||||
|
|||||||
@@ -507,6 +507,12 @@ func TestAutocompleteUsers(t *testing.T) {
|
|||||||
t.Fatal("should have many users")
|
t.Fatal("should have many users")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rusers, resp = Client.AutocompleteUsersInChannel("", channelId, "", "")
|
||||||
|
CheckNoError(t, resp)
|
||||||
|
if len(rusers.Users) < 2 {
|
||||||
|
t.Fatal("should have many users")
|
||||||
|
}
|
||||||
|
|
||||||
rusers, resp = Client.AutocompleteUsersInTeam(teamId, username, "")
|
rusers, resp = Client.AutocompleteUsersInTeam(teamId, username, "")
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user