1 import { Transaction } from 'sequelize'
2 import { ActivityDelete } from '../../../../shared/models/activitypub/activity'
3 import { database as db } from '../../../initializers'
4 import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models'
5 import { broadcastToFollowers } from './misc'
7 async function sendDeleteVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) {
8 const byAccount = videoChannel.Account
10 const data = await deleteActivityData(videoChannel.url, byAccount)
12 const accountsInvolved = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id)
13 accountsInvolved.push(byAccount)
15 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
18 async function sendDeleteVideo (video: VideoInstance, t: Transaction) {
19 const byAccount = video.VideoChannel.Account
21 const data = await deleteActivityData(video.url, byAccount)
23 const accountsInvolved = await db.VideoShare.loadAccountsByShare(video.id)
24 accountsInvolved.push(byAccount)
26 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
29 async function sendDeleteAccount (account: AccountInstance, t: Transaction) {
30 const data = await deleteActivityData(account.url, account)
32 return broadcastToFollowers(data, account, [ account ], t)
35 // ---------------------------------------------------------------------------
38 sendDeleteVideoChannel,
43 // ---------------------------------------------------------------------------
45 async function deleteActivityData (url: string, byAccount: AccountInstance) {
46 const activity: ActivityDelete = {