From 2c0ccd4b3f5ec5633879e6b42cd5175e4de207cc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Apr 2020 16:36:43 +0200 Subject: [PATCH] Do not support subscriptions to accounts --- server/controllers/api/users/my-subscriptions.ts | 1 + server/lib/job-queue/handlers/activitypub-follow.ts | 6 ++++++ server/middlewares/validators/user-subscriptions.ts | 1 - 3 files changed, 7 insertions(+), 1 deletion(-) 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) { const payload = { name, host, + assertIsChannel: true, followerActorId: user.Account.Actor.id } 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 = { name: string host: string isAutoFollow?: boolean + assertIsChannel?: boolean } async function processActivityPubFollow (job: Bull.Job) { @@ -34,6 +35,11 @@ async function processActivityPubFollow (job: Bull.Job) { targetActor = await getOrCreateActorAndServerAndModel(actorUrl, 'all') } + if (payload.assertIsChannel && !targetActor.VideoChannel) { + logger.warn('Do not follow %s@%s because it is not a channel.', name, host) + return + } + const fromActor = await ActorModel.load(payload.followerActorId) 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 = [ .json({ error: `Subscription ${req.params.uri} not found.` }) - .end() } res.locals.subscription = subscription