"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bulkRouter = void 0;
const tslib_1 = require("tslib");
const express_1 = (0, tslib_1.__importDefault)(require("express"));
const video_comment_1 = require("../../lib/video-comment");
const bulk_1 = require("../../middlewares/validators/bulk");
const video_comment_2 = require("../../models/video/video-comment");
const middlewares_1 = require("../../middlewares");
const bulkRouter = express_1.default.Router();
exports.bulkRouter = bulkRouter;
bulkRouter.post('/remove-comments-of', middlewares_1.authenticate, (0, middlewares_1.asyncMiddleware)(bulk_1.bulkRemoveCommentsOfValidator), (0, middlewares_1.asyncMiddleware)(bulkRemoveCommentsOf));
function bulkRemoveCommentsOf(req, res) {
    return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
        const account = res.locals.account;
        const body = req.body;
        const user = res.locals.oauth.token.User;
        const filter = body.scope === 'my-videos'
            ? { onVideosOfAccount: user.Account }
            : {};
        const comments = yield video_comment_2.VideoCommentModel.listForBulkDelete(account, filter);
        res.status(204).end();
        for (const comment of comments) {
            yield (0, video_comment_1.removeComment)(comment, req, res);
        }
    });
}
//# sourceMappingURL=bulk.js.map