1 import { Transaction } from 'sequelize'
2 import { ActivityDelete } from '../../../../shared/models/activitypub'
3 import { AccountModel } from '../../../models/account/account'
4 import { VideoModel } from '../../../models/video/video'
5 import { VideoChannelModel } from '../../../models/video/video-channel'
6 import { VideoChannelShareModel } from '../../../models/video/video-channel-share'
7 import { VideoShareModel } from '../../../models/video/video-share'
8 import { broadcastToFollowers } from './misc'
10 async function sendDeleteVideoChannel (videoChannel: VideoChannelModel, t: Transaction) {
11 const byAccount = videoChannel.Account
13 const data = deleteActivityData(videoChannel.url, byAccount)
15 const accountsInvolved = await VideoChannelShareModel.loadAccountsByShare(videoChannel.id, t)
16 accountsInvolved.push(byAccount)
18 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
21 async function sendDeleteVideo (video: VideoModel, t: Transaction) {
22 const byAccount = video.VideoChannel.Account
24 const data = deleteActivityData(video.url, byAccount)
26 const accountsInvolved = await VideoShareModel.loadAccountsByShare(video.id, t)
27 accountsInvolved.push(byAccount)
29 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
32 async function sendDeleteAccount (account: AccountModel, t: Transaction) {
33 const data = deleteActivityData(account.url, account)
35 return broadcastToFollowers(data, account, [ account ], t)
38 // ---------------------------------------------------------------------------
41 sendDeleteVideoChannel,
46 // ---------------------------------------------------------------------------
48 function deleteActivityData (url: string, byAccount: AccountModel): ActivityDelete {