From 4c1f4674425ffeb430aa07f3fccbb09837f36a34 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 30 Aug 2017 08:06:29 -0400 Subject: PLT-7379: Timestamp on deleted, ephemeral, or pending post is a permalink (#7295) * Removed permalink from system messages, general cleanup * Removed permalink from deleted messages * Removed permalink from pending messages * Fixed post_info tests * Changed permalink logic to remove permalinks from ephemeral messages, but leave them in place for system messages. * Fixed check style --- webapp/utils/post_utils.jsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'webapp/utils') diff --git a/webapp/utils/post_utils.jsx b/webapp/utils/post_utils.jsx index 83fb666af..1ff16a5ab 100644 --- a/webapp/utils/post_utils.jsx +++ b/webapp/utils/post_utils.jsx @@ -9,7 +9,7 @@ import UserStore from 'stores/user_store.jsx'; import ChannelStore from 'stores/channel_store.jsx'; export function isSystemMessage(post) { - return post.type && (post.type.lastIndexOf(Constants.SYSTEM_MESSAGE_PREFIX) === 0); + return Boolean(post.type && (post.type.lastIndexOf(Constants.SYSTEM_MESSAGE_PREFIX) === 0)); } export function isFromWebhook(post) { @@ -53,11 +53,11 @@ export function getProfilePicSrcForPost(post, user) { } export function canDeletePost(post) { - var isOwner = isPostOwner(post); - var isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); - var isTeamAdmin = TeamStore.isTeamAdminForCurrentTeam() || isSystemAdmin; - var isChannelAdmin = ChannelStore.isChannelAdminForCurrentChannel() || isTeamAdmin; - var isAdmin = isChannelAdmin || isTeamAdmin || isSystemAdmin; + const isOwner = isPostOwner(post); + const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); + const isTeamAdmin = TeamStore.isTeamAdminForCurrentTeam() || isSystemAdmin; + const isChannelAdmin = ChannelStore.isChannelAdminForCurrentChannel() || isTeamAdmin; + const isAdmin = isChannelAdmin || isTeamAdmin || isSystemAdmin; if (global.window.mm_license.IsLicensed === 'true') { return (global.window.mm_config.RestrictPostDelete === Constants.PERMISSIONS_DELETE_POST_ALL && (isOwner || isChannelAdmin)) || @@ -69,15 +69,14 @@ export function canDeletePost(post) { } export function canEditPost(post, editDisableAction) { - var isOwner = isPostOwner(post); - - var canEdit = isOwner && !isSystemMessage(post); + const isOwner = isPostOwner(post); + let canEdit = isOwner && !isSystemMessage(post); if (canEdit && global.window.mm_license.IsLicensed === 'true') { if (global.window.mm_config.AllowEditPost === Constants.ALLOW_EDIT_POST_NEVER) { canEdit = false; } else if (global.window.mm_config.AllowEditPost === Constants.ALLOW_EDIT_POST_TIME_LIMIT) { - var timeLeft = (post.create_at + (global.window.mm_config.PostEditTimeLimit * 1000)) - Utils.getTimestamp(); + const timeLeft = (post.create_at + (global.window.mm_config.PostEditTimeLimit * 1000)) - Utils.getTimestamp(); if (timeLeft > 0) { editDisableAction.fireAfter(timeLeft + 1000); } else { -- cgit v1.2.3-1-g7c22