aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send/send-delete.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-12 17:53:50 +0100
committerChocobozzz <me@florianbigard.com>2017-12-13 16:50:33 +0100
commit3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch)
treee5ca358287fca6ecacce83defcf23af1e8e9f419 /server/lib/activitypub/send/send-delete.ts
parentc893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff)
downloadPeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.gz
PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.zst
PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.zip
Move models to typescript-sequelize
Diffstat (limited to 'server/lib/activitypub/send/send-delete.ts')
-rw-r--r--server/lib/activitypub/send/send-delete.ts25
1 files changed, 13 insertions, 12 deletions
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts
index 8193790b3..0a45ea10f 100644
--- a/server/lib/activitypub/send/send-delete.ts
+++ b/server/lib/activitypub/send/send-delete.ts
@@ -1,32 +1,35 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityDelete } from '../../../../shared/models/activitypub/activity' 2import { ActivityDelete } from '../../../../shared/models/activitypub'
3import { database as db } from '../../../initializers' 3import { AccountModel } from '../../../models/account/account'
4import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models' 4import { VideoModel } from '../../../models/video/video'
5import { VideoChannelModel } from '../../../models/video/video-channel'
6import { VideoChannelShareModel } from '../../../models/video/video-channel-share'
7import { VideoShareModel } from '../../../models/video/video-share'
5import { broadcastToFollowers } from './misc' 8import { broadcastToFollowers } from './misc'
6 9
7async function sendDeleteVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) { 10async function sendDeleteVideoChannel (videoChannel: VideoChannelModel, t: Transaction) {
8 const byAccount = videoChannel.Account 11 const byAccount = videoChannel.Account
9 12
10 const data = deleteActivityData(videoChannel.url, byAccount) 13 const data = deleteActivityData(videoChannel.url, byAccount)
11 14
12 const accountsInvolved = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id, t) 15 const accountsInvolved = await VideoChannelShareModel.loadAccountsByShare(videoChannel.id, t)
13 accountsInvolved.push(byAccount) 16 accountsInvolved.push(byAccount)
14 17
15 return broadcastToFollowers(data, byAccount, accountsInvolved, t) 18 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
16} 19}
17 20
18async function sendDeleteVideo (video: VideoInstance, t: Transaction) { 21async function sendDeleteVideo (video: VideoModel, t: Transaction) {
19 const byAccount = video.VideoChannel.Account 22 const byAccount = video.VideoChannel.Account
20 23
21 const data = deleteActivityData(video.url, byAccount) 24 const data = deleteActivityData(video.url, byAccount)
22 25
23 const accountsInvolved = await db.VideoShare.loadAccountsByShare(video.id, t) 26 const accountsInvolved = await VideoShareModel.loadAccountsByShare(video.id, t)
24 accountsInvolved.push(byAccount) 27 accountsInvolved.push(byAccount)
25 28
26 return broadcastToFollowers(data, byAccount, accountsInvolved, t) 29 return broadcastToFollowers(data, byAccount, accountsInvolved, t)
27} 30}
28 31
29async function sendDeleteAccount (account: AccountInstance, t: Transaction) { 32async function sendDeleteAccount (account: AccountModel, t: Transaction) {
30 const data = deleteActivityData(account.url, account) 33 const data = deleteActivityData(account.url, account)
31 34
32 return broadcastToFollowers(data, account, [ account ], t) 35 return broadcastToFollowers(data, account, [ account ], t)
@@ -42,12 +45,10 @@ export {
42 45
43// --------------------------------------------------------------------------- 46// ---------------------------------------------------------------------------
44 47
45function deleteActivityData (url: string, byAccount: AccountInstance) { 48function deleteActivityData (url: string, byAccount: AccountModel): ActivityDelete {
46 const activity: ActivityDelete = { 49 return {
47 type: 'Delete', 50 type: 'Delete',
48 id: url, 51 id: url,
49 actor: byAccount.url 52 actor: byAccount.url
50 } 53 }
51
52 return activity
53} 54}