- const [ actorFollow, created ] = await ActorFollowModel.findOrCreate({
- where: {
- actorId: actor.id,
- targetActorId: targetActor.id
- },
- defaults: {
- actorId: actor.id,
- targetActorId: targetActor.id,
- state: 'accepted'
- },
+ const serverActor = await getServerActor()
+ const isFollowingInstance = targetActor.id === serverActor.id
+
+ if (isFollowingInstance && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) {
+ logger.info('Rejecting %s because instance followers are disabled.', targetActor.url)
+
+ sendReject(activityId, byActor, targetActor)
+
+ return { actorFollow: undefined as MActorFollowActors }
+ }
+
+ const [ actorFollow, created ] = await ActorFollowModel.findOrCreateCustom({
+ byActor,
+ targetActor,
+ activityId,
+ state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL
+ ? 'pending'
+ : 'accepted',