diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-08 14:04:57 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-08 14:06:23 +0200 |
commit | 5b9c965d5aa747f29b081289f930ee215fdc23c8 (patch) | |
tree | 1c726117525230d74235e7fa986eb72e7376fb6c /server/middlewares/validators/follows.ts | |
parent | 594d0c6a7c64b045c11508bb4e4b19b75b3fc557 (diff) | |
download | PeerTube-5b9c965d5aa747f29b081289f930ee215fdc23c8.tar.gz PeerTube-5b9c965d5aa747f29b081289f930ee215fdc23c8.tar.zst PeerTube-5b9c965d5aa747f29b081289f930ee215fdc23c8.zip |
Add ability to forbid followers
Diffstat (limited to 'server/middlewares/validators/follows.ts')
-rw-r--r-- | server/middlewares/validators/follows.ts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts index ef4151efe..38df39fda 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/middlewares/validators/follows.ts | |||
@@ -9,7 +9,6 @@ import { ActorFollowModel } from '../../models/activitypub/actor-follow' | |||
9 | import { areValidationErrors } from './utils' | 9 | import { areValidationErrors } from './utils' |
10 | import { ActorModel } from '../../models/activitypub/actor' | 10 | import { ActorModel } from '../../models/activitypub/actor' |
11 | import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' | 11 | import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' |
12 | import { getOrCreateActorAndServerAndModel } from '../../lib/activitypub' | ||
13 | import { isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' | 12 | import { isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' |
14 | 13 | ||
15 | const followValidator = [ | 14 | const followValidator = [ |
@@ -66,12 +65,16 @@ const removeFollowerValidator = [ | |||
66 | 65 | ||
67 | if (areValidationErrors(req, res)) return | 66 | if (areValidationErrors(req, res)) return |
68 | 67 | ||
69 | const serverActor = await getServerActor() | 68 | let follow: ActorFollowModel |
70 | 69 | try { | |
71 | const actorUrl = await loadActorUrlOrGetFromWebfinger(req.params.nameWithHost) | 70 | const actorUrl = await loadActorUrlOrGetFromWebfinger(req.params.nameWithHost) |
72 | const actor = await ActorModel.loadByUrl(actorUrl) | 71 | const actor = await ActorModel.loadByUrl(actorUrl) |
73 | 72 | ||
74 | const follow = await ActorFollowModel.loadByActorAndTarget(actor.id, serverActor.id) | 73 | const serverActor = await getServerActor() |
74 | follow = await ActorFollowModel.loadByActorAndTarget(actor.id, serverActor.id) | ||
75 | } catch (err) { | ||
76 | logger.warn('Cannot get actor from handle.', { handle: req.params.nameWithHost, err }) | ||
77 | } | ||
75 | 78 | ||
76 | if (!follow) { | 79 | if (!follow) { |
77 | return res | 80 | return res |