diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-08 15:18:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-08 15:18:04 +0200 |
commit | 14893eb71cb2d4ca47e07589c81958863603aba4 (patch) | |
tree | a6a5c3130058ca57c10ef15b8b6ee00ef78166ea /server/lib | |
parent | 5b9c965d5aa747f29b081289f930ee215fdc23c8 (diff) | |
download | PeerTube-14893eb71cb2d4ca47e07589c81958863603aba4.tar.gz PeerTube-14893eb71cb2d4ca47e07589c81958863603aba4.tar.zst PeerTube-14893eb71cb2d4ca47e07589c81958863603aba4.zip |
Add ability to manually approves instance followers in REST API
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/process/process-follow.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index cecf09b47..140bbe9f1 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts | |||
@@ -32,6 +32,8 @@ async function processFollow (actor: ActorModel, targetActorURL: string) { | |||
32 | 32 | ||
33 | const serverActor = await getServerActor() | 33 | const serverActor = await getServerActor() |
34 | if (targetActor.id === serverActor.id && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { | 34 | if (targetActor.id === serverActor.id && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { |
35 | logger.info('Rejecting %s because instance followers are disabled.', targetActor.url) | ||
36 | |||
35 | return sendReject(actor, targetActor) | 37 | return sendReject(actor, targetActor) |
36 | } | 38 | } |
37 | 39 | ||
@@ -43,7 +45,7 @@ async function processFollow (actor: ActorModel, targetActorURL: string) { | |||
43 | defaults: { | 45 | defaults: { |
44 | actorId: actor.id, | 46 | actorId: actor.id, |
45 | targetActorId: targetActor.id, | 47 | targetActorId: targetActor.id, |
46 | state: 'accepted' | 48 | state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL ? 'pending' : 'accepted' |
47 | }, | 49 | }, |
48 | transaction: t | 50 | transaction: t |
49 | }) | 51 | }) |
@@ -51,7 +53,7 @@ async function processFollow (actor: ActorModel, targetActorURL: string) { | |||
51 | actorFollow.ActorFollower = actor | 53 | actorFollow.ActorFollower = actor |
52 | actorFollow.ActorFollowing = targetActor | 54 | actorFollow.ActorFollowing = targetActor |
53 | 55 | ||
54 | if (actorFollow.state !== 'accepted') { | 56 | if (actorFollow.state !== 'accepted' && CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === false) { |
55 | actorFollow.state = 'accepted' | 57 | actorFollow.state = 'accepted' |
56 | await actorFollow.save({ transaction: t }) | 58 | await actorFollow.save({ transaction: t }) |
57 | } | 59 | } |
@@ -60,7 +62,7 @@ async function processFollow (actor: ActorModel, targetActorURL: string) { | |||
60 | actorFollow.ActorFollowing = targetActor | 62 | actorFollow.ActorFollowing = targetActor |
61 | 63 | ||
62 | // Target sends to actor he accepted the follow request | 64 | // Target sends to actor he accepted the follow request |
63 | await sendAccept(actorFollow) | 65 | if (actorFollow.state === 'accepted') await sendAccept(actorFollow) |
64 | 66 | ||
65 | return { actorFollow, created } | 67 | return { actorFollow, created } |
66 | }) | 68 | }) |