diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-16 16:36:43 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-04-16 16:37:25 +0200 |
commit | 2c0ccd4b3f5ec5633879e6b42cd5175e4de207cc (patch) | |
tree | ba4ee87af789e23086ce717e660b961320620d3b | |
parent | bd65cf02ff7fba8eced98a4fef0c45d9737ced80 (diff) | |
download | PeerTube-2c0ccd4b3f5ec5633879e6b42cd5175e4de207cc.tar.gz PeerTube-2c0ccd4b3f5ec5633879e6b42cd5175e4de207cc.tar.zst PeerTube-2c0ccd4b3f5ec5633879e6b42cd5175e4de207cc.zip |
Do not support subscriptions to accounts
-rw-r--r-- | server/controllers/api/users/my-subscriptions.ts | 1 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/activitypub-follow.ts | 6 | ||||
-rw-r--r-- | server/middlewares/validators/user-subscriptions.ts | 1 |
3 files changed, 7 insertions, 1 deletions
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index 888392b8b..efe1b9bc3 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts | |||
@@ -112,6 +112,7 @@ function addUserSubscription (req: express.Request, res: express.Response) { | |||
112 | const payload = { | 112 | const payload = { |
113 | name, | 113 | name, |
114 | host, | 114 | host, |
115 | assertIsChannel: true, | ||
115 | followerActorId: user.Account.Actor.id | 116 | followerActorId: user.Account.Actor.id |
116 | } | 117 | } |
117 | 118 | ||
diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index 4a7cda0a2..94eeed4c0 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts | |||
@@ -17,6 +17,7 @@ export type ActivitypubFollowPayload = { | |||
17 | name: string | 17 | name: string |
18 | host: string | 18 | host: string |
19 | isAutoFollow?: boolean | 19 | isAutoFollow?: boolean |
20 | assertIsChannel?: boolean | ||
20 | } | 21 | } |
21 | 22 | ||
22 | async function processActivityPubFollow (job: Bull.Job) { | 23 | async function processActivityPubFollow (job: Bull.Job) { |
@@ -34,6 +35,11 @@ async function processActivityPubFollow (job: Bull.Job) { | |||
34 | targetActor = await getOrCreateActorAndServerAndModel(actorUrl, 'all') | 35 | targetActor = await getOrCreateActorAndServerAndModel(actorUrl, 'all') |
35 | } | 36 | } |
36 | 37 | ||
38 | if (payload.assertIsChannel && !targetActor.VideoChannel) { | ||
39 | logger.warn('Do not follow %s@%s because it is not a channel.', name, host) | ||
40 | return | ||
41 | } | ||
42 | |||
37 | const fromActor = await ActorModel.load(payload.followerActorId) | 43 | const fromActor = await ActorModel.load(payload.followerActorId) |
38 | 44 | ||
39 | return retryTransactionWrapper(follow, fromActor, targetActor, payload.isAutoFollow) | 45 | return retryTransactionWrapper(follow, fromActor, targetActor, payload.isAutoFollow) |
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts index 9bc8c87e7..5d4cc94c5 100644 --- a/server/middlewares/validators/user-subscriptions.ts +++ b/server/middlewares/validators/user-subscriptions.ts | |||
@@ -53,7 +53,6 @@ const userSubscriptionGetValidator = [ | |||
53 | .json({ | 53 | .json({ |
54 | error: `Subscription ${req.params.uri} not found.` | 54 | error: `Subscription ${req.params.uri} not found.` |
55 | }) | 55 | }) |
56 | .end() | ||
57 | } | 56 | } |
58 | 57 | ||
59 | res.locals.subscription = subscription | 58 | res.locals.subscription = subscription |