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'
6 import { getVideoAbuseActivityPubUrl } from '../../../helpers/activitypub'
8 async function sendCreateVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) {
9 const byAccount = videoChannel.Account
11 const videoChannelObject = videoChannel.toActivityPubObject()
12 const data = await createActivityData(videoChannel.url, byAccount, videoChannelObject)
14 return broadcastToFollowers(data, byAccount, [ byAccount ], t)
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())
21 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
24 async function createActivityData (url: string, byAccount: AccountInstance, object: any) {
25 const { to, cc } = await getAudience(byAccount)
26 const activity: ActivityCreate = {
38 // ---------------------------------------------------------------------------
41 sendCreateVideoChannel,