Don't follow ourselves

pull/311/head
Chocobozzz 2018-02-23 14:48:30 +01:00
parent ab998f7b6d
commit 1ee48d1903
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 4 additions and 0 deletions

View File

@ -106,6 +106,10 @@ async function followRetry (req: express.Request, res: express.Response, next: e
} }
function follow (fromActor: ActorModel, targetActor: ActorModel) { 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 => { return sequelizeTypescript.transaction(async t => {
const [ actorFollow ] = await ActorFollowModel.findOrCreate({ const [ actorFollow ] = await ActorFollowModel.findOrCreate({
where: { where: {