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/lib/activitypub/send/send-reject.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/lib/activitypub/send/send-reject.ts')
-rw-r--r-- | server/lib/activitypub/send/send-reject.ts | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/server/lib/activitypub/send/send-reject.ts b/server/lib/activitypub/send/send-reject.ts index db8c2d86d..bac7ff556 100644 --- a/server/lib/activitypub/send/send-reject.ts +++ b/server/lib/activitypub/send/send-reject.ts | |||
@@ -1,15 +1,11 @@ | |||
1 | import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub' | 1 | import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub' |
2 | import { ActorModel } from '../../../models/activitypub/actor' | 2 | import { ActorModel } from '../../../models/activitypub/actor' |
3 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 3 | import { getActorFollowActivityPubUrl, getActorFollowRejectActivityPubUrl } from '../url' |
4 | import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url' | ||
5 | import { unicastTo } from './utils' | 4 | import { unicastTo } from './utils' |
6 | import { buildFollowActivity } from './send-follow' | 5 | import { buildFollowActivity } from './send-follow' |
7 | import { logger } from '../../../helpers/logger' | 6 | import { logger } from '../../../helpers/logger' |
8 | 7 | ||
9 | async function sendReject (actorFollow: ActorFollowModel) { | 8 | async function sendReject (follower: ActorModel, following: ActorModel) { |
10 | const follower = actorFollow.ActorFollower | ||
11 | const me = actorFollow.ActorFollowing | ||
12 | |||
13 | if (!follower.serverId) { // This should never happen | 9 | if (!follower.serverId) { // This should never happen |
14 | logger.warn('Do not sending reject to local follower.') | 10 | logger.warn('Do not sending reject to local follower.') |
15 | return | 11 | return |
@@ -17,13 +13,13 @@ async function sendReject (actorFollow: ActorFollowModel) { | |||
17 | 13 | ||
18 | logger.info('Creating job to reject follower %s.', follower.url) | 14 | logger.info('Creating job to reject follower %s.', follower.url) |
19 | 15 | ||
20 | const followUrl = getActorFollowActivityPubUrl(actorFollow) | 16 | const followUrl = getActorFollowActivityPubUrl(follower, following) |
21 | const followData = buildFollowActivity(followUrl, follower, me) | 17 | const followData = buildFollowActivity(followUrl, follower, following) |
22 | 18 | ||
23 | const url = getActorFollowAcceptActivityPubUrl(actorFollow) | 19 | const url = getActorFollowRejectActivityPubUrl(follower, following) |
24 | const data = buildRejectActivity(url, me, followData) | 20 | const data = buildRejectActivity(url, following, followData) |
25 | 21 | ||
26 | return unicastTo(data, me, follower.inboxUrl) | 22 | return unicastTo(data, following, follower.inboxUrl) |
27 | } | 23 | } |
28 | 24 | ||
29 | // --------------------------------------------------------------------------- | 25 | // --------------------------------------------------------------------------- |