[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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d9c2a8825b
Коммит
ac854498a4
@@ -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 {
|
||||
|
||||
Ссылка в новой задаче
Block a user