Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
MM-12815: TIdy up usage of advanced permissions deprecated configs. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
grundleborg authored and hmhealey committed Aug 28, 2020
1 parent 1b0fd93 commit a594d7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
4 changes: 4 additions & 0 deletions packages/mattermost-redux/src/utils/channel_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export function showCreateOption(state, config, license, teamId, channelType, is
return true;
}

// Backwards compatibility with pre-advanced permissions config settings.
if (channelType === General.OPEN_CHANNEL) {
if (config.RestrictPublicChannelCreation === General.SYSTEM_ADMIN_ROLE && !isSystemAdmin) {
return false;
Expand Down Expand Up @@ -269,6 +270,7 @@ export function showManagementOptions(state, config, license, channel, isAdmin,
return true;
}

// Backwards compatibility with pre-advanced permissions config settings.
if (channel.type === General.OPEN_CHANNEL) {
if (config.RestrictPublicChannelManagement === General.SYSTEM_ADMIN_ROLE && !isSystemAdmin) {
return false;
Expand Down Expand Up @@ -308,6 +310,7 @@ export function showDeleteOption(state, config, license, channel, isAdmin, isSys
return true;
}

// Backwards compatibility with pre-advanced permissions config settings.
if (channel.type === General.OPEN_CHANNEL) {
if (config.RestrictPublicChannelDeletion === General.SYSTEM_ADMIN_ROLE && !isSystemAdmin) {
return false;
Expand All @@ -333,6 +336,7 @@ export function showDeleteOption(state, config, license, channel, isAdmin, isSys
return true;
}

// Backwards compatibility with pre-advanced permissions config settings.
export function canManageMembersOldPermissions(channel, user, teamMember, channelMember, config, license) {
if (channel.type === General.DM_CHANNEL ||
channel.type === General.GM_CHANNEL ||
Expand Down
15 changes: 2 additions & 13 deletions packages/mattermost-redux/src/utils/post_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function canDeletePost(state, config, license, teamId, channelId, userId,
return canDelete;
}

// Backwards compatibility with pre-advanced permissions config settings.
if (license.IsLicensed === 'true') {
return (config.RestrictPostDelete === General.PERMISSIONS_ALL && (isOwner || isAdmin)) ||
(config.RestrictPostDelete === General.PERMISSIONS_TEAM_ADMIN && isAdmin) ||
Expand Down Expand Up @@ -88,6 +89,7 @@ export function canEditPost(state, config, license, teamId, channelId, userId, p
}
}
} else {
// Backwards compatibility with pre-advanced permissions config settings.
canEdit = isOwner && config.AllowEditPost !== 'never';
if (config.AllowEditPost === General.ALLOW_EDIT_POST_TIME_LIMIT) {
const timeLeft = (post.create_at + (config.PostEditTimeLimit * 1000)) - Date.now();
Expand All @@ -100,19 +102,6 @@ export function canEditPost(state, config, license, teamId, channelId, userId, p
return canEdit;
}

export function editDisable(state, config, license, teamId, channelId, userId, post, editDisableAction) {
const canEdit = canEditPost(state, config, license, teamId, channelId, userId, post);

if (canEdit && license.IsLicensed === 'true') {
if (config.AllowEditPost === General.ALLOW_EDIT_POST_TIME_LIMIT || (config.PostEditTimeLimit !== -1 && config.PostEditTimeLimit !== '-1')) {
const timeLeft = (post.create_at + (config.PostEditTimeLimit * 1000)) - Date.now();
if (timeLeft > 0) {
editDisableAction.fireAfter(timeLeft + 1000);
}
}
}
}

export function getLastCreateAt(postsArray) {
const createAt = postsArray.map((p) => p.create_at);

Expand Down

0 comments on commit a594d7a

Please sign in to comment.