X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Fsend%2Fsend-accept.ts;h=4eaa329d935cf81e2affa7b8710e891ec238eab1;hb=e12a009254de33bcdbd8334992980fa029c3e10d;hp=eeab19ed01c59c94384bfa4751c35444dfe83207;hpb=892211e8493b1f992fce7616cb1e48b7ff87a1dc;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/send/send-accept.ts b/server/lib/activitypub/send/send-accept.ts index eeab19ed0..4eaa329d9 100644 --- a/server/lib/activitypub/send/send-accept.ts +++ b/server/lib/activitypub/send/send-accept.ts @@ -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 = await 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 { // --------------------------------------------------------------------------- -async 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 }