-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) {
+ 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)
- return unicastTo(data, me, follower.inboxUrl, t)
+ const url = getActorFollowAcceptActivityPubUrl(actorFollow)
+ const data = acceptActivityData(url, me, followData)
+
+ return unicastTo(data, me, follower.inboxUrl)
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
-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
}