aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-23 14:48:30 +0100
committerChocobozzz <me@florianbigard.com>2018-02-23 14:48:30 +0100
commit1ee48d19036199169eca061f1ecccd2f2c8fd359 (patch)
tree30fdf740665e6480129c1b9c917f65dfb373806c /server
parentab998f7b6dffbe461d830d3696cb46491ad6afb0 (diff)
downloadPeerTube-1ee48d19036199169eca061f1ecccd2f2c8fd359.tar.gz
PeerTube-1ee48d19036199169eca061f1ecccd2f2c8fd359.tar.zst
PeerTube-1ee48d19036199169eca061f1ecccd2f2c8fd359.zip
Don't follow ourselves
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/server/follows.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index bb8713e7a..4a0a44cd3 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -106,6 +106,10 @@ async function followRetry (req: express.Request, res: express.Response, next: e
106} 106}
107 107
108function follow (fromActor: ActorModel, targetActor: ActorModel) { 108function follow (fromActor: ActorModel, targetActor: ActorModel) {
109 if (fromActor.id === targetActor.id) {
110 throw new Error('Follower is the same than target actor.')
111 }
112
109 return sequelizeTypescript.transaction(async t => { 113 return sequelizeTypescript.transaction(async t => {
110 const [ actorFollow ] = await ActorFollowModel.findOrCreate({ 114 const [ actorFollow ] = await ActorFollowModel.findOrCreate({
111 where: { 115 where: {