MM-38611 getSharedChannels: only return channels user is member of (#18417)

* getSharedChannels: only return channels user is member of
Этот коммит содержится в:
Doug Lauder
2021-09-20 15:00:47 -04:00
коммит произвёл GitHub
родитель 8a7af3bef2
Коммит a1b853d1dc
5 изменённых файлов: 100 добавлений и 6 удалений

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

@@ -27,10 +27,21 @@ func getSharedChannels(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
// make sure user has access to the team.
if !c.App.SessionHasPermissionToTeam(*c.AppContext.Session(), c.Params.TeamId, model.PermissionViewTeam) {
c.SetPermissionError(model.PermissionViewTeam)
return
}
opts := model.SharedChannelFilterOpts{
TeamId: c.Params.TeamId,
}
// only return channels the user is a member of, unless they are a shared channels manager.
if !c.App.HasPermissionTo(c.AppContext.Session().UserId, model.PermissionManageSharedChannels) {
opts.MemberId = c.AppContext.Session().UserId
}
channels, appErr := c.App.GetSharedChannels(c.Params.Page, c.Params.PerPage, opts)
if appErr != nil {
c.Err = appErr