diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-27 15:45:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-07-27 15:45:04 +0200 |
commit | 50cc1ee48aacb6e7d6513c0f108492a589b515ea (patch) | |
tree | c4b634c6aa30d60daefc9952242260a55bf52577 /server/lib | |
parent | bfcaa9c1947304c9f90843bc288d3d8f64a71097 (diff) | |
download | PeerTube-50cc1ee48aacb6e7d6513c0f108492a589b515ea.tar.gz PeerTube-50cc1ee48aacb6e7d6513c0f108492a589b515ea.tar.zst PeerTube-50cc1ee48aacb6e7d6513c0f108492a589b515ea.zip |
Fix process follow
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/process/process-follow.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index e633cd3ae..da660bda3 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts | |||
@@ -40,7 +40,7 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ | |||
40 | if (!targetActor) throw new Error('Unknown actor') | 40 | if (!targetActor) throw new Error('Unknown actor') |
41 | if (targetActor.isOwned() === false) throw new Error('This is not a local actor.') | 41 | if (targetActor.isOwned() === false) throw new Error('This is not a local actor.') |
42 | 42 | ||
43 | if (rejectIfInstanceFollowDisabled(byActor, activityId, targetActor)) return { actorFollow: undefined } | 43 | if (await rejectIfInstanceFollowDisabled(byActor, activityId, targetActor)) return { actorFollow: undefined } |
44 | if (await rejectIfMuted(byActor, activityId, targetActor)) return { actorFollow: undefined } | 44 | if (await rejectIfMuted(byActor, activityId, targetActor)) return { actorFollow: undefined } |
45 | 45 | ||
46 | const [ actorFollow, created ] = await ActorFollowModel.findOrCreateCustom({ | 46 | const [ actorFollow, created ] = await ActorFollowModel.findOrCreateCustom({ |
@@ -79,7 +79,7 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ | |||
79 | const follower = await ActorModel.loadFull(byActor.id) | 79 | const follower = await ActorModel.loadFull(byActor.id) |
80 | const actorFollowFull = Object.assign(actorFollow, { ActorFollowing: targetActor, ActorFollower: follower }) | 80 | const actorFollowFull = Object.assign(actorFollow, { ActorFollowing: targetActor, ActorFollower: follower }) |
81 | 81 | ||
82 | if (isFollowingInstance(targetActor)) { | 82 | if (await isFollowingInstance(targetActor)) { |
83 | Notifier.Instance.notifyOfNewInstanceFollow(actorFollowFull) | 83 | Notifier.Instance.notifyOfNewInstanceFollow(actorFollowFull) |
84 | } else { | 84 | } else { |
85 | Notifier.Instance.notifyOfNewUserFollow(actorFollowFull) | 85 | Notifier.Instance.notifyOfNewUserFollow(actorFollowFull) |
@@ -89,8 +89,8 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ | |||
89 | logger.info('Actor %s is followed by actor %s.', targetActorURL, byActor.url) | 89 | logger.info('Actor %s is followed by actor %s.', targetActorURL, byActor.url) |
90 | } | 90 | } |
91 | 91 | ||
92 | function rejectIfInstanceFollowDisabled (byActor: MActorSignature, activityId: string, targetActor: MActorFull) { | 92 | async function rejectIfInstanceFollowDisabled (byActor: MActorSignature, activityId: string, targetActor: MActorFull) { |
93 | if (isFollowingInstance(targetActor) && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { | 93 | if (await isFollowingInstance(targetActor) && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { |
94 | logger.info('Rejecting %s because instance followers are disabled.', targetActor.url) | 94 | logger.info('Rejecting %s because instance followers are disabled.', targetActor.url) |
95 | 95 | ||
96 | sendReject(activityId, byActor, targetActor) | 96 | sendReject(activityId, byActor, targetActor) |
@@ -133,7 +133,7 @@ async function acceptIfNeeded (actorFollow: MActorFollow, targetActor: MActorFul | |||
133 | // Set the follow as accepted if the remote actor follows a channel or account | 133 | // Set the follow as accepted if the remote actor follows a channel or account |
134 | // Or if the instance automatically accepts followers | 134 | // Or if the instance automatically accepts followers |
135 | if (actorFollow.state === 'accepted') return | 135 | if (actorFollow.state === 'accepted') return |
136 | if (!isFollowingInstance(targetActor)) return | 136 | if (!await isFollowingInstance(targetActor)) return |
137 | if (CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === true) return | 137 | if (CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === true) return |
138 | 138 | ||
139 | actorFollow.state = 'accepted' | 139 | actorFollow.state = 'accepted' |