diff options
Diffstat (limited to 'server/lib/activitypub/process')
-rw-r--r-- | server/lib/activitypub/process/process-follow.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index 0cd537187..cecf09b47 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts | |||
@@ -1,12 +1,13 @@ | |||
1 | import { ActivityFollow } from '../../../../shared/models/activitypub' | 1 | import { ActivityFollow } from '../../../../shared/models/activitypub' |
2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { sequelizeTypescript } from '../../../initializers' | 4 | import { sequelizeTypescript, CONFIG } from '../../../initializers' |
5 | import { ActorModel } from '../../../models/activitypub/actor' | 5 | import { ActorModel } from '../../../models/activitypub/actor' |
6 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 6 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
7 | import { sendAccept } from '../send' | 7 | import { sendAccept, sendReject } from '../send' |
8 | import { Notifier } from '../../notifier' | 8 | import { Notifier } from '../../notifier' |
9 | import { getAPId } from '../../../helpers/activitypub' | 9 | import { getAPId } from '../../../helpers/activitypub' |
10 | import { getServerActor } from '../../../helpers/utils' | ||
10 | 11 | ||
11 | async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) { | 12 | async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) { |
12 | const activityObject = getAPId(activity.object) | 13 | const activityObject = getAPId(activity.object) |
@@ -29,6 +30,11 @@ async function processFollow (actor: ActorModel, targetActorURL: string) { | |||
29 | if (!targetActor) throw new Error('Unknown actor') | 30 | if (!targetActor) throw new Error('Unknown actor') |
30 | if (targetActor.isOwned() === false) throw new Error('This is not a local actor.') | 31 | if (targetActor.isOwned() === false) throw new Error('This is not a local actor.') |
31 | 32 | ||
33 | const serverActor = await getServerActor() | ||
34 | if (targetActor.id === serverActor.id && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { | ||
35 | return sendReject(actor, targetActor) | ||
36 | } | ||
37 | |||
32 | const [ actorFollow, created ] = await ActorFollowModel.findOrCreate({ | 38 | const [ actorFollow, created ] = await ActorFollowModel.findOrCreate({ |
33 | where: { | 39 | where: { |
34 | actorId: actor.id, | 40 | actorId: actor.id, |