Do not support subscriptions to accounts
authorChocobozzz <me@florianbigard.com>
Thu, 16 Apr 2020 14:36:43 +0000 (16:36 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 16 Apr 2020 14:37:25 +0000 (16:37 +0200)
server/controllers/api/users/my-subscriptions.ts
server/lib/job-queue/handlers/activitypub-follow.ts
server/middlewares/validators/user-subscriptions.ts

index 888392b8b3bde4a9b6bcd9faf8f8efea17967bb4..efe1b9bc3838a922bc7126331ba8703f77805c36 100644 (file)
@@ -112,6 +112,7 @@ function addUserSubscription (req: express.Request, res: express.Response) {
   const payload = {
     name,
     host,
+    assertIsChannel: true,
     followerActorId: user.Account.Actor.id
   }
 
index 4a7cda0a2ba74e216b3d76aa1a769833f604e884..94eeed4c0f2db13fdd328b75748ddd8693f2ce1d 100644 (file)
@@ -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)
index 9bc8c87e74b28164d3cd4edd9c896a71607d2d92..5d4cc94c52c3db5e2e3424980e89edbdde00d550 100644 (file)
@@ -53,7 +53,6 @@ const userSubscriptionGetValidator = [
         .json({
           error: `Subscription ${req.params.uri} not found.`
         })
-        .end()
     }
 
     res.locals.subscription = subscription