]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/activitypub/send/send-accept.ts
Better follows tests
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-accept.ts
1 import { Transaction } from 'sequelize'
2 import { ActivityAccept } from '../../../../shared/models/activitypub/activity'
3 import { AccountInstance } from '../../../models'
4 import { AccountFollowInstance } from '../../../models/account/account-follow-interface'
5 import { unicastTo } from './misc'
6 import { getAccountFollowAcceptActivityPubUrl } from '../url'
7
8 async function sendAccept (accountFollow: AccountFollowInstance, t: Transaction) {
9 const follower = accountFollow.AccountFollower
10 const me = accountFollow.AccountFollowing
11
12 const url = getAccountFollowAcceptActivityPubUrl(accountFollow)
13 const data = await acceptActivityData(url, me)
14
15 return unicastTo(data, me, follower.inboxUrl, t)
16 }
17
18 // ---------------------------------------------------------------------------
19
20 export {
21 sendAccept
22 }
23
24 // ---------------------------------------------------------------------------
25
26 async function acceptActivityData (url: string, byAccount: AccountInstance) {
27 const activity: ActivityAccept = {
28 type: 'Accept',
29 id: url,
30 actor: byAccount.url
31 }
32
33 return activity
34 }