"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.canEditPostV2 = canEditPostV2;
const channel_permission_1 = require("../channel-permission");
/**
 * Utility to determine if User has privileges to modify a post
 * @param post
 * @param user
 * @param channel
 * @returns {boolean}
 */
function canEditPostV2(post, user = {}, channel) {
    const canReplyOrPost = post.parentId ? channel.allowReply : channel.allowPost;
    const channelPermission = new channel_permission_1.ChannelPermission(channel);
    return (isPostCreator(post, user) &&
        canReplyOrPost &&
        channelPermission.canPostToChannel(user));
}
function isPostCreator(post, user) {
    return !!user.username && post.creator === user.username;
}
//# sourceMappingURL=can-edit-post-v2.js.map