]>
Commit | Line | Data |
---|---|---|
54141398 C |
1 | import { Transaction } from 'sequelize' |
2 | import { ActivityAdd } from '../../../../shared/models/activitypub/activity' | |
3 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | |
4 | import { AccountInstance, VideoInstance } from '../../../models' | |
5 | import { broadcastToFollowers, getAudience } from './misc' | |
6 | ||
7 | async function sendAddVideo (video: VideoInstance, t: Transaction) { | |
8 | const byAccount = video.VideoChannel.Account | |
9 | ||
10 | const videoObject = video.toActivityPubObject() | |
25ed141c | 11 | const data = await addActivityData(video.url, byAccount, video, video.VideoChannel.url, videoObject, t) |
54141398 C |
12 | |
13 | return broadcastToFollowers(data, byAccount, [ byAccount ], t) | |
14 | } | |
15 | ||
25ed141c C |
16 | async function addActivityData ( |
17 | url: string, | |
18 | byAccount: AccountInstance, | |
19 | video: VideoInstance, | |
20 | target: string, | |
21 | object: any, | |
22 | t: Transaction | |
23 | ) { | |
54141398 C |
24 | const videoPublic = video.privacy === VideoPrivacy.PUBLIC |
25 | ||
25ed141c | 26 | const { to, cc } = await getAudience(byAccount, t, videoPublic) |
54141398 C |
27 | const activity: ActivityAdd = { |
28 | type: 'Add', | |
29 | id: url, | |
30 | actor: byAccount.url, | |
31 | to, | |
32 | cc, | |
33 | object, | |
34 | target | |
35 | } | |
36 | ||
37 | return activity | |
38 | } | |
39 | ||
40 | // --------------------------------------------------------------------------- | |
41 | ||
42 | export { | |
43 | addActivityData, | |
44 | sendAddVideo | |
45 | } |