From 436a2352f3f9ecb457fc0035f3fa0e8c8728a010 Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Wed, 4 Sep 2024 12:11:12 +0530 Subject: [PATCH 1/3] [MM-564]: Fixed the subscribe permissions config preventing system admins from creating subscriptions in DM or GM --- server/subscribe.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/subscribe.go b/server/subscribe.go index ce6ee2960..8885464c5 100644 --- a/server/subscribe.go +++ b/server/subscribe.go @@ -684,7 +684,7 @@ func (p *Plugin) hasPermissionToManageSubscription(instanceID types.ID, userID, switch cfg.RolesAllowedToEditJiraSubscriptions { case "team_admin": - if !p.client.User.HasPermissionToChannel(userID, channelID, model.PermissionManageTeam) { + if !p.client.User.HasPermissionTo(userID, model.PermissionManageTeam) { return errors.New("is not team admin") } case "channel_admin": @@ -702,7 +702,9 @@ func (p *Plugin) hasPermissionToManageSubscription(instanceID types.ID, userID, return errors.New("is not channel admin") } default: - return errors.New("can only subscribe in public and private channels") + if !p.client.User.HasPermissionTo(userID, model.PermissionManageSystem) { + return errors.New("is not system admin") + } } case "users": default: From bd206dfd947d0682f593c075e56b4386648a0248 Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Mon, 9 Sep 2024 13:08:44 +0530 Subject: [PATCH 2/3] [MM-564]: review fixes --- server/subscribe.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/subscribe.go b/server/subscribe.go index 8885464c5..e67ed605e 100644 --- a/server/subscribe.go +++ b/server/subscribe.go @@ -684,7 +684,7 @@ func (p *Plugin) hasPermissionToManageSubscription(instanceID types.ID, userID, switch cfg.RolesAllowedToEditJiraSubscriptions { case "team_admin": - if !p.client.User.HasPermissionTo(userID, model.PermissionManageTeam) { + if !p.client.User.HasPermissionToChannel(userID, channelID, model.PermissionManageTeam) { return errors.New("is not team admin") } case "channel_admin": From e21ce6370f58a7917d6a3d4c5b2cbaf0b3325e82 Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Tue, 17 Sep 2024 10:08:37 +0530 Subject: [PATCH 3/3] [MM-564]: reverted the changes regarding creating subscription in DM/GM --- server/subscribe.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/subscribe.go b/server/subscribe.go index e67ed605e..ce6ee2960 100644 --- a/server/subscribe.go +++ b/server/subscribe.go @@ -702,9 +702,7 @@ func (p *Plugin) hasPermissionToManageSubscription(instanceID types.ID, userID, return errors.New("is not channel admin") } default: - if !p.client.User.HasPermissionTo(userID, model.PermissionManageSystem) { - return errors.New("is not system admin") - } + return errors.New("can only subscribe in public and private channels") } case "users": default: