"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.processViewActivity = void 0;
const tslib_1 = require("tslib");
const video_views_1 = require("../../video-views");
const utils_1 = require("../send/utils");
const videos_1 = require("../videos");
function processViewActivity(options) {
    return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
        const { activity, byActor } = options;
        return processCreateView(activity, byActor);
    });
}
exports.processViewActivity = processViewActivity;
function processCreateView(activity, byActor) {
    return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
        const videoObject = activity.object;
        const { video } = yield (0, videos_1.getOrCreateAPVideo)({
            videoObject,
            fetchType: 'only-video',
            allowRefresh: false
        });
        const viewerExpires = activity.expires
            ? new Date(activity.expires)
            : undefined;
        yield video_views_1.VideoViews.Instance.processView({ video, ip: null, viewerExpires });
        if (video.isOwned()) {
            const exceptions = [byActor];
            yield (0, utils_1.forwardVideoRelatedActivity)(activity, undefined, exceptions, video);
        }
    });
}
//# sourceMappingURL=process-view.js.map