]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/send/send-accept.ts
Split files in activitypub server
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-accept.ts
index 7579884a79ca43f241a5d325e9bfda903f1918e9..44644a22f3d57189e9c35b36c9cb750f345c2006 100644 (file)
@@ -1,18 +1,21 @@
-import { Transaction } from 'sequelize'
-import { ActivityAccept } from '../../../../shared/models/activitypub'
+import { ActivityAccept, ActivityFollow } from '../../../../shared/models/activitypub'
 import { ActorModel } from '../../../models/activitypub/actor'
 import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
-import { getActorFollowAcceptActivityPubUrl } from '../url'
-import { unicastTo } from './misc'
+import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url'
+import { unicastTo } from './utils'
+import { followActivityData } from './send-follow'
 
-async function sendAccept (actorFollow: ActorFollowModel, t: Transaction) {
+async function sendAccept (actorFollow: ActorFollowModel) {
   const follower = actorFollow.ActorFollower
   const me = actorFollow.ActorFollowing
 
+  const followUrl = getActorFollowActivityPubUrl(actorFollow)
+  const followData = followActivityData(followUrl, follower, me)
+
   const url = getActorFollowAcceptActivityPubUrl(actorFollow)
-  const data = acceptActivityData(url, me)
+  const data = acceptActivityData(url, me, followData)
 
-  return unicastTo(data, me, follower.inboxUrl, t)
+  return unicastTo(data, me, follower.inboxUrl)
 }
 
 // ---------------------------------------------------------------------------
@@ -23,10 +26,11 @@ export {
 
 // ---------------------------------------------------------------------------
 
-function acceptActivityData (url: string, byActor: ActorModel): ActivityAccept {
+function acceptActivityData (url: string, byActor: ActorModel, followActivityData: ActivityFollow): ActivityAccept {
   return {
     type: 'Accept',
     id: url,
-    actor: byActor.url
+    actor: byActor.url,
+    object: followActivityData
   }
 }