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