import { ChannelPermission } from "../channel-permission";
import { hasOrgAdminUpdateRights } from "../portal-privilege";
/**
 * Utility to determine if User has privileges to delete a post
 * @deprecated replace with canDeletePostV2 for v2 discussions
 * @export
 * @param post
 * @param user
 * @param channel
 * @returns {boolean}
 */
export function canDeletePost(post, channel, user = {}) {
    return isPostCreator(post, user) || isChannelModerator(channel, user);
}
function isPostCreator(post, user) {
    return !!user.username && post.creator === user.username;
}
function isChannelModerator(channel, user) {
    if (hasOrgAdminUpdateRights(user, channel.orgId)) {
        return true;
    }
    if (!channel.channelAcl) {
        return false;
    }
    const channelPermission = new ChannelPermission(channel);
    return channelPermission.canModerateChannel(user);
}
//# sourceMappingURL=can-delete-post.js.map