]>
Commit | Line | Data |
---|---|---|
54141398 | 1 | import { Transaction } from 'sequelize' |
e71bcc0f C |
2 | import { ActivityAdd } from '../../../../shared/index' |
3 | import { ActivityAnnounce, ActivityCreate } from '../../../../shared/models/activitypub/activity' | |
54141398 C |
4 | import { AccountInstance, VideoInstance } from '../../../models' |
5 | import { VideoChannelInstance } from '../../../models/video/video-channel-interface' | |
e71bcc0f | 6 | import { getAnnounceActivityPubUrl } from '../url' |
54141398 C |
7 | import { broadcastToFollowers } from './misc' |
8 | import { addActivityData } from './send-add' | |
9 | import { createActivityData } from './send-create' | |
54141398 C |
10 | |
11 | async function sendVideoAnnounce (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { | |
12 | const url = getAnnounceActivityPubUrl(video.url, byAccount) | |
13 | ||
14 | const videoChannel = video.VideoChannel | |
15 | const announcedActivity = await addActivityData(url, videoChannel.Account, video, videoChannel.url, video.toActivityPubObject()) | |
16 | ||
17 | const data = await announceActivityData(url, byAccount, announcedActivity) | |
18 | return broadcastToFollowers(data, byAccount, [ byAccount ], t) | |
19 | } | |
20 | ||
21 | async function sendVideoChannelAnnounce (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { | |
22 | const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount) | |
23 | const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject()) | |
24 | ||
25 | const data = await announceActivityData(url, byAccount, announcedActivity) | |
26 | return broadcastToFollowers(data, byAccount, [ byAccount ], t) | |
27 | } | |
28 | ||
e71bcc0f C |
29 | async function announceActivityData (url: string, byAccount: AccountInstance, object: ActivityCreate | ActivityAdd) { |
30 | const activity: ActivityAnnounce = { | |
54141398 C |
31 | type: 'Announce', |
32 | id: url, | |
33 | actor: byAccount.url, | |
34 | object | |
35 | } | |
36 | ||
37 | return activity | |
38 | } | |
e71bcc0f C |
39 | |
40 | // --------------------------------------------------------------------------- | |
41 | ||
42 | export { | |
43 | sendVideoAnnounce, | |
44 | sendVideoChannelAnnounce, | |
45 | announceActivityData | |
46 | } |