From 22a16e36f6526887ed8f5e5d3c9f9e5da0b4a8cd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 21 Aug 2018 16:18:59 +0200 Subject: Add local user subscriptions --- server/lib/job-queue/handlers/activitypub-follow.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'server/lib/job-queue') diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index 282dde268..36d0f237b 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts @@ -1,7 +1,6 @@ import * as Bull from 'bull' import { logger } from '../../../helpers/logger' -import { getServerActor } from '../../../helpers/utils' -import { REMOTE_SCHEME, sequelizeTypescript } from '../../../initializers' +import { CONFIG, REMOTE_SCHEME, sequelizeTypescript } from '../../../initializers' import { sendFollow } from '../../activitypub/send' import { sanitizeHost } from '../../../helpers/core-utils' import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' @@ -22,10 +21,14 @@ async function processActivityPubFollow (job: Bull.Job) { logger.info('Processing ActivityPub follow in job %d.', job.id) - const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP) - - const actorUrl = await loadActorUrlOrGetFromWebfinger(payload.name + '@' + sanitizedHost) - const targetActor = await getOrCreateActorAndServerAndModel(actorUrl) + let targetActor: ActorModel + if (!host || host === CONFIG.WEBSERVER.HOST) { + targetActor = await ActorModel.loadLocalByName(payload.name) + } else { + const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP) + const actorUrl = await loadActorUrlOrGetFromWebfinger(payload.name + '@' + sanitizedHost) + targetActor = await getOrCreateActorAndServerAndModel(actorUrl) + } const fromActor = await ActorModel.load(payload.followerActorId) -- cgit v1.2.3