From 6ae03a098e5c4ebdecec7ef58b6d270ce840ccc2 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Tue, 6 Aug 2024 08:56:25 -0400 Subject: [PATCH] [MM-58492] Remove subsequent check for team permissions on open channels (#27827) * [MM-58492] Remove subsequent check for team permissions on open channels * Removed extra check for open channel for webhooks as well --------- Co-authored-by: Mattermost Build --- server/channels/api4/post.go | 4 +--- server/channels/api4/webhook.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/server/channels/api4/post.go b/server/channels/api4/post.go index 718b84b1a8..d41f58e3f2 100644 --- a/server/channels/api4/post.go +++ b/server/channels/api4/post.go @@ -572,9 +572,7 @@ func getPostsByIds(c *Context, w http.ResponseWriter, r *http.Request) { } if !c.App.SessionHasPermissionToReadChannel(c.AppContext, *c.AppContext.Session(), channel) { - if channel.Type != model.ChannelTypeOpen || (channel.Type == model.ChannelTypeOpen && !c.App.SessionHasPermissionToTeam(*c.AppContext.Session(), channel.TeamId, model.PermissionReadPublicChannel)) { - continue - } + continue } post = c.App.PreparePostForClient(c.AppContext, post, false, false, true) diff --git a/server/channels/api4/webhook.go b/server/channels/api4/webhook.go index b305140baa..8f3c47b4d8 100644 --- a/server/channels/api4/webhook.go +++ b/server/channels/api4/webhook.go @@ -51,7 +51,7 @@ func createIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) { return } - if channel.Type != model.ChannelTypeOpen && !c.App.SessionHasPermissionToReadChannel(c.AppContext, *c.AppContext.Session(), channel) { + if !c.App.SessionHasPermissionToReadChannel(c.AppContext, *c.AppContext.Session(), channel) { c.LogAudit("fail - bad channel permissions") c.SetPermissionError(model.PermissionReadChannelContent) return