]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/activitypub/send/send-delete.ts
Fix req accepts
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-delete.ts
CommitLineData
54141398
C
1import { Transaction } from 'sequelize'
2import { ActivityDelete } from '../../../../shared/models/activitypub/activity'
3import { database as db } from '../../../initializers'
4import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models'
5import { broadcastToFollowers } from './misc'
6
7async function sendDeleteVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) {
8 const byAccount = videoChannel.Account
9
25ed141c 10 const data = deleteActivityData(videoChannel.url, byAccount)
54141398 11
25ed141c 12 const accountsInvolved = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id, t)
54141398
C
13 accountsInvolved.push(byAccount)
14
15 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
16}
17
18async function sendDeleteVideo (video: VideoInstance, t: Transaction) {
19 const byAccount = video.VideoChannel.Account
20
25ed141c 21 const data = deleteActivityData(video.url, byAccount)
54141398 22
25ed141c 23 const accountsInvolved = await db.VideoShare.loadAccountsByShare(video.id, t)
54141398
C
24 accountsInvolved.push(byAccount)
25
26 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
27}
28
29async function sendDeleteAccount (account: AccountInstance, t: Transaction) {
98ec8b8e 30 const data = deleteActivityData(account.url, account)
54141398
C
31
32 return broadcastToFollowers(data, account, [ account ], t)
33}
34
35// ---------------------------------------------------------------------------
36
37export {
38 sendDeleteVideoChannel,
39 sendDeleteVideo,
40 sendDeleteAccount
41}
42
43// ---------------------------------------------------------------------------
44
25ed141c 45function deleteActivityData (url: string, byAccount: AccountInstance) {
54141398
C
46 const activity: ActivityDelete = {
47 type: 'Delete',
48 id: url,
49 actor: byAccount.url
50 }
51
52 return activity
53}