aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/follows.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-08 14:04:57 +0200
committerChocobozzz <me@florianbigard.com>2019-04-08 14:06:23 +0200
commit5b9c965d5aa747f29b081289f930ee215fdc23c8 (patch)
tree1c726117525230d74235e7fa986eb72e7376fb6c /server/middlewares/validators/follows.ts
parent594d0c6a7c64b045c11508bb4e4b19b75b3fc557 (diff)
downloadPeerTube-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.ts15
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'
9import { areValidationErrors } from './utils' 9import { areValidationErrors } from './utils'
10import { ActorModel } from '../../models/activitypub/actor' 10import { ActorModel } from '../../models/activitypub/actor'
11import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' 11import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger'
12import { getOrCreateActorAndServerAndModel } from '../../lib/activitypub'
13import { isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' 12import { isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
14 13
15const followValidator = [ 14const 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