"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildFollowActivity = exports.sendFollow = void 0;
const logger_1 = require("../../../helpers/logger");
const send_utils_1 = require("./shared/send-utils");
function sendFollow(actorFollow, t) {
    const me = actorFollow.ActorFollower;
    const following = actorFollow.ActorFollowing;
    if (!following.serverId)
        return;
    logger_1.logger.info('Creating job to send follow request to %s.', following.url);
    const data = buildFollowActivity(actorFollow.url, me, following);
    return t.afterCommit(() => {
        return (0, send_utils_1.unicastTo)({ data, byActor: me, toActorUrl: following.inboxUrl, contextType: 'Follow' });
    });
}
exports.sendFollow = sendFollow;
function buildFollowActivity(url, byActor, targetActor) {
    return {
        type: 'Follow',
        id: url,
        actor: byActor.url,
        object: targetActor.url
    };
}
exports.buildFollowActivity = buildFollowActivity;
//# sourceMappingURL=send-follow.js.map