[MM-64445] api4/channels_test: Add tests cases for guest user private channels (#31319) (#33776)

Automatic Merge
Этот коммит содержится в:
Mattermost Build
2025-08-22 11:34:05 +03:00
коммит произвёл GitHub
родитель 6dd8c55207
Коммит 24c4a3677b
2 изменённых файлов: 109 добавлений и 7 удалений

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

@@ -1857,9 +1857,22 @@ func addChannelMember(c *Context, w http.ResponseWriter, r *http.Request) {
// Security check: if the user is a guest, they must have access to the channel
// to view its members
if c.AppContext.Session().IsGuest() && !c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), c.Params.ChannelId, model.PermissionReadChannel) {
c.SetPermissionError(model.PermissionReadChannel)
return
if c.AppContext.Session().IsGuest() {
if !c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), c.Params.ChannelId, model.PermissionReadChannel) {
c.SetPermissionError(model.PermissionReadChannel)
return
}
for _, userId := range userIds {
allowed, appErr := c.App.UserCanSeeOtherUser(c.AppContext, c.AppContext.Session().UserId, userId)
if appErr != nil {
c.Err = appErr
return
}
if !allowed {
c.SetPermissionError(model.PermissionInviteUser)
return
}
}
}
if channel.Type == model.ChannelTypeDirect || channel.Type == model.ChannelTypeGroup {