]>
Commit | Line | Data |
---|---|---|
54141398 C |
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' | |
6 | ||
7 | async 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 | ||
18 | async 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 | ||
29 | async function sendDeleteAccount (account: AccountInstance, t: Transaction) { | |
30 | const data = await deleteActivityData(account.url, account) | |
31 | ||
32 | return broadcastToFollowers(data, account, [ account ], t) | |
33 | } | |
34 | ||
35 | // --------------------------------------------------------------------------- | |
36 | ||
37 | export { | |
38 | sendDeleteVideoChannel, | |
39 | sendDeleteVideo, | |
40 | sendDeleteAccount | |
41 | } | |
42 | ||
43 | // --------------------------------------------------------------------------- | |
44 | ||
25ed141c | 45 | function 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 | } |