diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-12 17:53:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-13 16:50:33 +0100 |
commit | 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch) | |
tree | e5ca358287fca6ecacce83defcf23af1e8e9f419 /server/lib/activitypub/send/send-delete.ts | |
parent | c893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff) | |
download | PeerTube-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.ts | 25 |
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 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { ActivityDelete } from '../../../../shared/models/activitypub/activity' | 2 | import { ActivityDelete } from '../../../../shared/models/activitypub' |
3 | import { database as db } from '../../../initializers' | 3 | import { AccountModel } from '../../../models/account/account' |
4 | import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models' | 4 | import { VideoModel } from '../../../models/video/video' |
5 | import { VideoChannelModel } from '../../../models/video/video-channel' | ||
6 | import { VideoChannelShareModel } from '../../../models/video/video-channel-share' | ||
7 | import { VideoShareModel } from '../../../models/video/video-share' | ||
5 | import { broadcastToFollowers } from './misc' | 8 | import { broadcastToFollowers } from './misc' |
6 | 9 | ||
7 | async function sendDeleteVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) { | 10 | async 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 | ||
18 | async function sendDeleteVideo (video: VideoInstance, t: Transaction) { | 21 | async 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 | ||
29 | async function sendDeleteAccount (account: AccountInstance, t: Transaction) { | 32 | async 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 | ||
45 | function deleteActivityData (url: string, byAccount: AccountInstance) { | 48 | function 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 | } |