Take view archived config into account on users and posts api endpoints (#19014)

* Take view archived config into account on users and posts api endpoints

* Move the inChannel check to the top level
Этот коммит содержится в:
Miguel de la Cruz
2021-11-25 15:01:17 +01:00
коммит произвёл GitHub
родитель 8588f69850
Коммит 009d02c57a
5 изменённых файлов: 102 добавлений и 0 удалений

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

@@ -735,6 +735,20 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
var profiles []*model.User
etag := ""
if inChannelId != "" {
if !*c.App.Config().TeamSettings.ExperimentalViewArchivedChannels {
channel, appErr := c.App.GetChannel(inChannelId)
if appErr != nil {
c.Err = appErr
return
}
if channel.DeleteAt != 0 {
c.Err = model.NewAppError("Api4.getUsersInChannel", "api.user.view_archived_channels.get_users_in_channel.app_error", nil, "", http.StatusForbidden)
return
}
}
}
if withoutTeamBool, _ := strconv.ParseBool(withoutTeam); withoutTeamBool {
// Use a special permission for now
if !c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionListUsersWithoutTeam) {
@@ -784,6 +798,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
c.SetPermissionError(model.PermissionReadChannel)
return
}
if sort == "status" {
profiles, err = c.App.GetUsersInChannelPageByStatus(userGetOptions, c.IsSystemAdmin())
} else {