]>
Commit | Line | Data |
---|---|---|
54141398 C |
1 | import { Transaction } from 'sequelize' |
2 | import { ActivityCreate } from '../../../../shared/models/activitypub/activity' | |
3 | import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models' | |
4 | import { VideoAbuseInstance } from '../../../models/video/video-abuse-interface' | |
5 | import { broadcastToFollowers, getAudience, unicastTo } from './misc' | |
892211e8 | 6 | import { getVideoAbuseActivityPubUrl } from '../url' |
54141398 C |
7 | |
8 | async 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 | ||
17 | async 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 |
26 | async 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 | ||
42 | export { | |
43 | sendCreateVideoChannel, | |
44 | sendVideoAbuse, | |
45 | createActivityData | |
46 | } |