From 350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 14 Nov 2017 17:31:26 +0100 Subject: Follow works --- server/lib/activitypub/process-follow.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'server/lib/activitypub/process-follow.ts') diff --git a/server/lib/activitypub/process-follow.ts b/server/lib/activitypub/process-follow.ts index ee5d97a0b..a805c0757 100644 --- a/server/lib/activitypub/process-follow.ts +++ b/server/lib/activitypub/process-follow.ts @@ -36,14 +36,18 @@ async function follow (account: AccountInstance, targetAccountURL: string) { if (targetAccount === undefined) throw new Error('Unknown account') if (targetAccount.isOwned() === false) throw new Error('This is not a local account.') - const sequelizeOptions = { + await db.AccountFollow.findOrCreate({ + where: { + accountId: account.id, + targetAccountId: targetAccount.id + }, + defaults: { + accountId: account.id, + targetAccountId: targetAccount.id, + state: 'accepted' + }, transaction: t - } - await db.AccountFollow.create({ - accountId: account.id, - targetAccountId: targetAccount.id, - state: 'accepted' - }, sequelizeOptions) + }) // Target sends to account he accepted the follow request return sendAccept(targetAccount, account, t) -- cgit v1.2.3