[MM-56266] Check for public channels when getting channel member counts to avoid 403 errors (#25831)

* [MM-56266] Check for public channels when getting channel member counts to avoid 403 errors

* Fix test
Этот коммит содержится в:
Devin Binnie
2024-01-05 12:28:22 -05:00
коммит произвёл GitHub
родитель d9c2a8825b
Коммит ac854498a4
2 изменённых файлов: 21 добавлений и 4 удалений

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

@@ -698,11 +698,19 @@ func getChannelsMemberCount(c *Context, w http.ResponseWriter, r *http.Request)
}
channelIDs := model.ArrayFromJSON(r.Body)
if !c.App.SessionHasPermissionToChannels(c.AppContext, *c.AppContext.Session(), channelIDs, model.PermissionReadChannel) {
c.SetPermissionError(model.PermissionReadChannel)
channels, err := c.App.GetChannels(c.AppContext, channelIDs)
if err != nil {
c.Err = err
return
}
for _, channel := range channels {
if !c.App.HasPermissionToReadChannel(c.AppContext, c.AppContext.Session().UserId, channel) {
c.SetPermissionError(model.PermissionReadChannel)
return
}
}
channelsMemberCount, err := c.App.GetChannelsMemberCount(c.AppContext, channelIDs)
if err != nil {