]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/send/send-accept.ts
Status are sent to mastodon
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-accept.ts
index d3f8fbe38475dced9725849aeeaff49306f756b2..4eaa329d935cf81e2affa7b8710e891ec238eab1 100644 (file)
@@ -1,16 +1,20 @@
 import { Transaction } from 'sequelize'
-import { ActivityAccept } from '../../../../shared/models/activitypub/activity'
-import { AccountInstance } from '../../../models'
-import { AccountFollowInstance } from '../../../models/account/account-follow-interface'
+import { ActivityAccept, ActivityFollow } from '../../../../shared/models/activitypub'
+import { ActorModel } from '../../../models/activitypub/actor'
+import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
+import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url'
 import { unicastTo } from './misc'
-import { getAccountFollowAcceptActivityPubUrl } from '../url'
+import { followActivityData } from './send-follow'
 
-async function sendAccept (accountFollow: AccountFollowInstance, t: Transaction) {
-  const follower = accountFollow.AccountFollower
-  const me = accountFollow.AccountFollowing
+async function sendAccept (actorFollow: ActorFollowModel, t: Transaction) {
+  const follower = actorFollow.ActorFollower
+  const me = actorFollow.ActorFollowing
 
-  const url = getAccountFollowAcceptActivityPubUrl(accountFollow)
-  const data = acceptActivityData(url, me)
+  const followUrl = getActorFollowActivityPubUrl(actorFollow)
+  const followData = followActivityData(followUrl, follower, me)
+
+  const url = getActorFollowAcceptActivityPubUrl(actorFollow)
+  const data = acceptActivityData(url, me, followData)
 
   return unicastTo(data, me, follower.inboxUrl, t)
 }
@@ -23,12 +27,11 @@ export {
 
 // ---------------------------------------------------------------------------
 
-function acceptActivityData (url: string, byAccount: AccountInstance) {
-  const activity: ActivityAccept = {
+function acceptActivityData (url: string, byActor: ActorModel, followActivityData: ActivityFollow): ActivityAccept {
+  return {
     type: 'Accept',
     id: url,
-    actor: byAccount.url
+    actor: byActor.url,
+    object: followActivityData
   }
-
-  return activity
 }