"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.canDeletePostV2 = canDeletePostV2;
const channel_permission_1 = require("../channel-permission");
const portal_privilege_1 = require("../portal-privilege");
/**
 * Utility to determine if User has privileges to delete a post
 * @export
 * @param post
 * @param user
 * @param channel
 * @returns {boolean}
 */
function canDeletePostV2(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 ((0, portal_privilege_1.hasOrgAdminUpdateRights)(user, channel.orgId)) {
        return true;
    }
    const channelPermission = new channel_permission_1.ChannelPermission(channel);
    return channelPermission.canModerateChannel(user);
}
//# sourceMappingURL=can-delete-post-v2.js.map