]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/process/process-follow.ts
Correctly forward like/dislikes and undo
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / process / process-follow.ts
index 5536395800aa26db4f0651a2ffefd6f9d65f6237..320dc113814f74757c52f6e5fa753bf8f291ead1 100644 (file)
@@ -1,13 +1,14 @@
 import { ActivityFollow } from '../../../../shared/models/activitypub/activity'
-import { getOrCreateAccount, retryTransactionWrapper } from '../../../helpers'
+import { retryTransactionWrapper } from '../../../helpers'
 import { database as db } from '../../../initializers'
 import { AccountInstance } from '../../../models/account/account-interface'
 import { logger } from '../../../helpers/logger'
 import { sendAccept } from '../send/send-accept'
+import { getOrCreateAccountAndServer } from '../account'
 
 async function processFollowActivity (activity: ActivityFollow) {
   const activityObject = activity.object
-  const account = await getOrCreateAccount(activity.actor)
+  const account = await getOrCreateAccountAndServer(activity.actor)
 
   return processFollow(account, activityObject)
 }
@@ -48,6 +49,12 @@ async function follow (account: AccountInstance, targetAccountURL: string) {
       },
       transaction: t
     })
+
+    if (accountFollow.state !== 'accepted') {
+      accountFollow.state = 'accepted'
+      await accountFollow.save({ transaction: t })
+    }
+
     accountFollow.AccountFollower = account
     accountFollow.AccountFollowing = targetAccount