X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Fsend%2Fsend-accept.ts;h=44644a22f3d57189e9c35b36c9cb750f345c2006;hb=e251f170b00b2014ac4e823113c6ff40e3fb1471;hp=0324a30fa02397d46d87d150ff234317c1cf093f;hpb=54141398354e6e7b94aa3065a705a1251390111c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/send/send-accept.ts b/server/lib/activitypub/send/send-accept.ts index 0324a30fa..44644a22f 100644 --- a/server/lib/activitypub/send/send-accept.ts +++ b/server/lib/activitypub/send/send-accept.ts @@ -1,18 +1,21 @@ -import { Transaction } from 'sequelize' -import { ActivityAccept } from '../../../../shared/models/activitypub/activity' -import { AccountInstance } from '../../../models' -import { AccountFollowInstance } from '../../../models/account/account-follow-interface' -import { unicastTo } from './misc' -import { getAccountFollowAcceptActivityPubUrl } from '../../../helpers/activitypub' +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 './utils' +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 = await 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) } // --------------------------------------------------------------------------- @@ -23,12 +26,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 }