"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.processFederateVideo = void 0;
const tslib_1 = require("tslib");
const database_utils_1 = require("../../../helpers/database-utils");
const database_1 = require("../../../initializers/database");
const videos_1 = require("../../activitypub/videos");
const video_1 = require("../../../models/video/video");
const logger_1 = require("../../../helpers/logger");
function processFederateVideo(job) {
    const payload = job.data;
    logger_1.logger.info('Processing video federation in job %s.', job.id);
    return (0, database_utils_1.retryTransactionWrapper)(() => {
        return database_1.sequelizeTypescript.transaction((t) => tslib_1.__awaiter(this, void 0, void 0, function* () {
            const video = yield video_1.VideoModel.loadFull(payload.videoUUID, t);
            if (!video)
                return;
            return (0, videos_1.federateVideoIfNeeded)(video, payload.isNewVideo, t);
        }));
    });
}
exports.processFederateVideo = processFederateVideo;
//# sourceMappingURL=federate-video.js.map