"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bulkRemoveCommentsOfValidator = void 0;
const tslib_1 = require("tslib");
const express_validator_1 = require("express-validator");
const bulk_1 = require("../../helpers/custom-validators/bulk");
const shared_1 = require("./shared");
const bulkRemoveCommentsOfValidator = [
    (0, express_validator_1.body)('accountName')
        .exists(),
    (0, express_validator_1.body)('scope')
        .custom(bulk_1.isBulkRemoveCommentsOfScopeValid),
    (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
        if ((0, shared_1.areValidationErrors)(req, res))
            return;
        if (!(yield (0, shared_1.doesAccountNameWithHostExist)(req.body.accountName, res)))
            return;
        const user = res.locals.oauth.token.User;
        const body = req.body;
        if (body.scope === 'instance' && user.hasRight(16) !== true) {
            return res.fail({
                status: 403,
                message: 'User cannot remove any comments of this instance.'
            });
        }
        return next();
    })
];
exports.bulkRemoveCommentsOfValidator = bulkRemoveCommentsOfValidator;
//# sourceMappingURL=bulk.js.map