]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Don't follow ourselves
authorChocobozzz <me@florianbigard.com>
Fri, 23 Feb 2018 13:48:30 +0000 (14:48 +0100)
committerChocobozzz <me@florianbigard.com>
Fri, 23 Feb 2018 13:48:30 +0000 (14:48 +0100)
server/controllers/api/server/follows.ts

index bb8713e7a00a8903abcac4d0dd02bd6d461a29bb..4a0a44cd395f7959e0ec8433f5dffa8c107034b4 100644 (file)
@@ -106,6 +106,10 @@ async function followRetry (req: express.Request, res: express.Response, next: e
 }
 
 function follow (fromActor: ActorModel, targetActor: ActorModel) {
+  if (fromActor.id === targetActor.id) {
+    throw new Error('Follower is the same than target actor.')
+  }
+
   return sequelizeTypescript.transaction(async t => {
     const [ actorFollow ] = await ActorFollowModel.findOrCreate({
       where: {