]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/activitypub/send/send-create.ts
Fetch outbox to grab old activities
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-create.ts
CommitLineData
54141398
C
1import { Transaction } from 'sequelize'
2import { ActivityCreate } from '../../../../shared/models/activitypub/activity'
3import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models'
4import { VideoAbuseInstance } from '../../../models/video/video-abuse-interface'
5import { broadcastToFollowers, getAudience, unicastTo } from './misc'
892211e8 6import { getVideoAbuseActivityPubUrl } from '../url'
54141398
C
7
8async function sendCreateVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) {
9 const byAccount = videoChannel.Account
10
11 const videoChannelObject = videoChannel.toActivityPubObject()
12 const data = await createActivityData(videoChannel.url, byAccount, videoChannelObject)
13
14 return broadcastToFollowers(data, byAccount, [ byAccount ], t)
15}
16
17async function sendVideoAbuse (byAccount: AccountInstance, videoAbuse: VideoAbuseInstance, video: VideoInstance, t: Transaction) {
18 const url = getVideoAbuseActivityPubUrl(videoAbuse)
19 const data = await createActivityData(url, byAccount, videoAbuse.toActivityPubObject())
20
21 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
22}
23
c986175d
C
24// async function sendCreateView ()
25
54141398
C
26async function createActivityData (url: string, byAccount: AccountInstance, object: any) {
27 const { to, cc } = await getAudience(byAccount)
28 const activity: ActivityCreate = {
29 type: 'Create',
30 id: url,
31 actor: byAccount.url,
32 to,
33 cc,
34 object
35 }
36
37 return activity
38}
39
40// ---------------------------------------------------------------------------
41
42export {
43 sendCreateVideoChannel,
44 sendVideoAbuse,
45 createActivityData
46}