aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-follow.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/process/process-follow.ts')
-rw-r--r--server/lib/activitypub/process/process-follow.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts
index 320dc1138..ccaee43a6 100644
--- a/server/lib/activitypub/process/process-follow.ts
+++ b/server/lib/activitypub/process/process-follow.ts
@@ -1,10 +1,10 @@
1import { ActivityFollow } from '../../../../shared/models/activitypub/activity' 1import { ActivityFollow } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers' 2import { logger, retryTransactionWrapper } from '../../../helpers'
3import { database as db } from '../../../initializers' 3import { sequelizeTypescript } from '../../../initializers'
4import { AccountInstance } from '../../../models/account/account-interface' 4import { AccountModel } from '../../../models/account/account'
5import { logger } from '../../../helpers/logger' 5import { AccountFollowModel } from '../../../models/account/account-follow'
6import { sendAccept } from '../send/send-accept'
7import { getOrCreateAccountAndServer } from '../account' 6import { getOrCreateAccountAndServer } from '../account'
7import { sendAccept } from '../send'
8 8
9async function processFollowActivity (activity: ActivityFollow) { 9async function processFollowActivity (activity: ActivityFollow) {
10 const activityObject = activity.object 10 const activityObject = activity.object
@@ -21,7 +21,7 @@ export {
21 21
22// --------------------------------------------------------------------------- 22// ---------------------------------------------------------------------------
23 23
24function processFollow (account: AccountInstance, targetAccountURL: string) { 24function processFollow (account: AccountModel, targetAccountURL: string) {
25 const options = { 25 const options = {
26 arguments: [ account, targetAccountURL ], 26 arguments: [ account, targetAccountURL ],
27 errorMessage: 'Cannot follow with many retries.' 27 errorMessage: 'Cannot follow with many retries.'
@@ -30,14 +30,14 @@ function processFollow (account: AccountInstance, targetAccountURL: string) {
30 return retryTransactionWrapper(follow, options) 30 return retryTransactionWrapper(follow, options)
31} 31}
32 32
33async function follow (account: AccountInstance, targetAccountURL: string) { 33async function follow (account: AccountModel, targetAccountURL: string) {
34 await db.sequelize.transaction(async t => { 34 await sequelizeTypescript.transaction(async t => {
35 const targetAccount = await db.Account.loadByUrl(targetAccountURL, t) 35 const targetAccount = await AccountModel.loadByUrl(targetAccountURL, t)
36 36
37 if (!targetAccount) throw new Error('Unknown account') 37 if (!targetAccount) throw new Error('Unknown account')
38 if (targetAccount.isOwned() === false) throw new Error('This is not a local account.') 38 if (targetAccount.isOwned() === false) throw new Error('This is not a local account.')
39 39
40 const [ accountFollow ] = await db.AccountFollow.findOrCreate({ 40 const [ accountFollow ] = await AccountFollowModel.findOrCreate({
41 where: { 41 where: {
42 accountId: account.id, 42 accountId: account.id,
43 targetAccountId: targetAccount.id 43 targetAccountId: targetAccount.id