]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/activitypub/send/send-follow.ts
Move models to typescript-sequelize
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-follow.ts
CommitLineData
54141398 1import { Transaction } from 'sequelize'
3fd3ab2d
C
2import { ActivityFollow } from '../../../../shared/models/activitypub'
3import { AccountModel } from '../../../models/account/account'
4import { AccountFollowModel } from '../../../models/account/account-follow'
892211e8 5import { getAccountFollowActivityPubUrl } from '../url'
54141398 6import { unicastTo } from './misc'
54141398 7
3fd3ab2d 8function sendFollow (accountFollow: AccountFollowModel, t: Transaction) {
54141398
C
9 const me = accountFollow.AccountFollower
10 const following = accountFollow.AccountFollowing
11
12 const url = getAccountFollowActivityPubUrl(accountFollow)
25ed141c 13 const data = followActivityData(url, me, following)
54141398
C
14
15 return unicastTo(data, me, following.inboxUrl, t)
16}
17
3fd3ab2d
C
18function followActivityData (url: string, byAccount: AccountModel, targetAccount: AccountModel): ActivityFollow {
19 return {
54141398
C
20 type: 'Follow',
21 id: url,
22 actor: byAccount.url,
23 object: targetAccount.url
24 }
54141398
C
25}
26
27// ---------------------------------------------------------------------------
28
29export {
30 sendFollow,
31 followActivityData
32}