"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.videosShareValidator = void 0;
const tslib_1 = require("tslib");
const express_validator_1 = require("express-validator");
const misc_1 = require("../../../helpers/custom-validators/misc");
const video_share_1 = require("../../../models/video/video-share");
const shared_1 = require("../shared");
const videosShareValidator = [
    (0, shared_1.isValidVideoIdParam)('id'),
    (0, express_validator_1.param)('actorId')
        .custom(misc_1.isIdValid),
    (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.doesVideoExist)(req.params.id, res)))
            return;
        const video = res.locals.videoAll;
        const share = yield video_share_1.VideoShareModel.load(req.params.actorId, video.id);
        if (!share) {
            return res.status(404)
                .end();
        }
        res.locals.videoShare = share;
        return next();
    })
];
exports.videosShareValidator = videosShareValidator;
//# sourceMappingURL=video-shares.js.map