"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildLikeActivity = exports.sendLike = void 0;
const logger_1 = require("../../../helpers/logger");
const audience_1 = require("../audience");
const url_1 = require("../url");
const send_utils_1 = require("./shared/send-utils");
function sendLike(byActor, video, transaction) {
    logger_1.logger.info('Creating job to like %s.', video.url);
    const activityBuilder = (audience) => {
        const url = (0, url_1.getVideoLikeActivityPubUrlByLocalActor)(byActor, video);
        return buildLikeActivity(url, byActor, video, audience);
    };
    return (0, send_utils_1.sendVideoActivityToOrigin)(activityBuilder, { byActor, video, transaction, contextType: 'Rate' });
}
exports.sendLike = sendLike;
function buildLikeActivity(url, byActor, video, audience) {
    if (!audience)
        audience = (0, audience_1.getAudience)(byActor);
    return (0, audience_1.audiencify)({
        id: url,
        type: 'Like',
        actor: byActor.url,
        object: video.url
    }, audience);
}
exports.buildLikeActivity = buildLikeActivity;
//# sourceMappingURL=send-like.js.map