]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/send/send-follow.ts
Convert followers/following in raw SQL queries
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-follow.ts
index 08f1d83f98b9a592097086a40aecd2768a3ccda7..57501dadb0551eecf31342749be1bf9a4ca60fd9 100644 (file)
@@ -1,9 +1,8 @@
-import { ActivityFollow } from '../../../../shared/models/activitypub'
-import { getActorFollowActivityPubUrl } from '../url'
-import { unicastTo } from './utils'
-import { logger } from '../../../helpers/logger'
 import { Transaction } from 'sequelize'
+import { ActivityFollow } from '@shared/models'
+import { logger } from '../../../helpers/logger'
 import { MActor, MActorFollowActors } from '../../../types/models'
+import { unicastTo } from './shared/send-utils'
 
 function sendFollow (actorFollow: MActorFollowActors, t: Transaction) {
   const me = actorFollow.ActorFollower
@@ -14,10 +13,11 @@ function sendFollow (actorFollow: MActorFollowActors, t: Transaction) {
 
   logger.info('Creating job to send follow request to %s.', following.url)
 
-  const url = getActorFollowActivityPubUrl(me, following)
-  const data = buildFollowActivity(url, me, following)
+  const data = buildFollowActivity(actorFollow.url, me, following)
 
-  t.afterCommit(() => unicastTo(data, me, following.inboxUrl))
+  return t.afterCommit(() => {
+    return unicastTo({ data, byActor: me, toActorUrl: following.inboxUrl, contextType: 'Follow' })
+  })
 }
 
 function buildFollowActivity (url: string, byActor: MActor, targetActor: MActor): ActivityFollow {