MM-27909: Add manage_shared_channels permission (#15601)
* MM-27909: Add manage_shared_channels permission We add a new permission to manage shared channels. It's a channel scoped permission and only the system admin has that by default. https://mattermost.atlassian.net/browse/MM-27909 * change to system scoped * Trigger CI * Trigger CI Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
96f1739f8f
Коммит
72432ab3ff
@@ -180,6 +180,7 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
|
||||
},
|
||||
"system_admin": allPermissionIDs,
|
||||
}
|
||||
assert.Contains(t, allPermissionIDs, model.PERMISSION_MANAGE_SHARED_CHANNELS.Id, "manage_shared_channels permission not found")
|
||||
|
||||
// Check the migration matches what's expected.
|
||||
for name, permissions := range expected1 {
|
||||
|
||||
@@ -69,6 +69,7 @@ const (
|
||||
PERMISSION_READ_PUBLIC_CHANNEL_GROUPS = "read_public_channel_groups"
|
||||
PERMISSION_READ_PRIVATE_CHANNEL_GROUPS = "read_private_channel_groups"
|
||||
PERMISSION_EDIT_BRAND = "edit_brand"
|
||||
PERMISSION_MANAGE_SHARED_CHANNELS = "manage_shared_channels"
|
||||
)
|
||||
|
||||
func isRole(roleName string) func(*model.Role, map[string]map[string]bool) bool {
|
||||
@@ -501,6 +502,15 @@ func (a *App) getAddConvertChannelPermissionsMigration() (permissionsMap, error)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *App) getAddManageSharedChannelsPermissionsMigration() (permissionsMap, error) {
|
||||
return permissionsMap{
|
||||
permissionTransformation{
|
||||
On: isRole(model.SYSTEM_ADMIN_ROLE_ID),
|
||||
Add: []string{PERMISSION_MANAGE_SHARED_CHANNELS},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DoPermissionsMigrations execute all the permissions migrations need by the current version.
|
||||
func (a *App) DoPermissionsMigrations() error {
|
||||
PermissionsMigrations := []struct {
|
||||
@@ -520,6 +530,7 @@ func (a *App) DoPermissionsMigrations() error {
|
||||
{Key: model.MIGRATION_KEY_ADD_USE_GROUP_MENTIONS_PERMISSION, Migration: a.getAddUseGroupMentionsPermissionMigration},
|
||||
{Key: model.MIGRATION_KEY_ADD_SYSTEM_CONSOLE_PERMISSIONS, Migration: a.getAddSystemConsolePermissionsMigration},
|
||||
{Key: model.MIGRATION_KEY_ADD_CONVERT_CHANNEL_PERMISSIONS, Migration: a.getAddConvertChannelPermissionsMigration},
|
||||
{Key: model.MIGRATION_KEY_ADD_MANAGE_SHARED_CHANNEL_PERMISSIONS, Migration: a.getAddManageSharedChannelsPermissionsMigration},
|
||||
}
|
||||
|
||||
for _, migration := range PermissionsMigrations {
|
||||
|
||||
Ссылка в новой задаче
Block a user