2017-11-20 02:43:39 -06:00
|
|
|
import { Transaction } from 'sequelize'
|
|
|
|
import { ActivityDelete } from '../../../../shared/models/activitypub/activity'
|
|
|
|
import { database as db } from '../../../initializers'
|
|
|
|
import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models'
|
|
|
|
import { broadcastToFollowers } from './misc'
|
|
|
|
|
|
|
|
async function sendDeleteVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) {
|
|
|
|
const byAccount = videoChannel.Account
|
|
|
|
|
2017-11-30 04:31:15 -06:00
|
|
|
const data = deleteActivityData(videoChannel.url, byAccount)
|
2017-11-20 02:43:39 -06:00
|
|
|
|
2017-11-30 04:31:15 -06:00
|
|
|
const accountsInvolved = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id, t)
|
2017-11-20 02:43:39 -06:00
|
|
|
accountsInvolved.push(byAccount)
|
|
|
|
|
|
|
|
return broadcastToFollowers(data, byAccount, accountsInvolved, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function sendDeleteVideo (video: VideoInstance, t: Transaction) {
|
|
|
|
const byAccount = video.VideoChannel.Account
|
|
|
|
|
2017-11-30 04:31:15 -06:00
|
|
|
const data = deleteActivityData(video.url, byAccount)
|
2017-11-20 02:43:39 -06:00
|
|
|
|
2017-11-30 04:31:15 -06:00
|
|
|
const accountsInvolved = await db.VideoShare.loadAccountsByShare(video.id, t)
|
2017-11-20 02:43:39 -06:00
|
|
|
accountsInvolved.push(byAccount)
|
|
|
|
|
|
|
|
return broadcastToFollowers(data, byAccount, accountsInvolved, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function sendDeleteAccount (account: AccountInstance, t: Transaction) {
|
|
|
|
const data = await deleteActivityData(account.url, account)
|
|
|
|
|
|
|
|
return broadcastToFollowers(data, account, [ account ], t)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
sendDeleteVideoChannel,
|
|
|
|
sendDeleteVideo,
|
|
|
|
sendDeleteAccount
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2017-11-30 04:31:15 -06:00
|
|
|
function deleteActivityData (url: string, byAccount: AccountInstance) {
|
2017-11-20 02:43:39 -06:00
|
|
|
const activity: ActivityDelete = {
|
|
|
|
type: 'Delete',
|
|
|
|
id: url,
|
|
|
|
actor: byAccount.url
|
|
|
|
}
|
|
|
|
|
|
|
|
return activity
|
|
|
|
}
|