"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.processNotify = void 0;
const tslib_1 = require("tslib");
const notifier_1 = require("../../notifier");
const video_1 = require("../../../models/video/video");
const logger_1 = require("../../../helpers/logger");
function processNotify(job) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const payload = job.data;
        logger_1.logger.info('Processing %s notification in job %s.', payload.action, job.id);
        if (payload.action === 'new-video')
            return doNotifyNewVideo(payload);
    });
}
exports.processNotify = processNotify;
function doNotifyNewVideo(payload) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const refreshedVideo = yield video_1.VideoModel.loadFull(payload.videoUUID);
        if (!refreshedVideo)
            return;
        notifier_1.Notifier.Instance.notifyOnNewVideoIfNeeded(refreshedVideo);
    });
}
//# sourceMappingURL=notify.js.map