diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-14 17:38:41 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-19 10:53:16 +0100 |
commit | 50d6de9c286abcb34ff4234d56d9cbb803db7665 (patch) | |
tree | f1732b27edcd05c7877a8358b8312f1e38c287ed /server/lib/activitypub/send/send-delete.ts | |
parent | fadf619ad61a016c1c7fc53de5a8f398a4f77519 (diff) | |
download | PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.gz PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.zst PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.zip |
Begin moving video channel to actor
Diffstat (limited to 'server/lib/activitypub/send/send-delete.ts')
-rw-r--r-- | server/lib/activitypub/send/send-delete.ts | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index 0a45ea10f..4bc5db77e 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/lib/activitypub/send/send-delete.ts | |||
@@ -1,54 +1,40 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { ActivityDelete } from '../../../../shared/models/activitypub' | 2 | import { ActivityDelete } from '../../../../shared/models/activitypub' |
3 | import { AccountModel } from '../../../models/account/account' | 3 | import { ActorModel } from '../../../models/activitypub/actor' |
4 | import { VideoModel } from '../../../models/video/video' | 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 { VideoShareModel } from '../../../models/video/video-share' |
8 | import { broadcastToFollowers } from './misc' | 6 | import { broadcastToFollowers } from './misc' |
9 | 7 | ||
10 | async function sendDeleteVideoChannel (videoChannel: VideoChannelModel, t: Transaction) { | ||
11 | const byAccount = videoChannel.Account | ||
12 | |||
13 | const data = deleteActivityData(videoChannel.url, byAccount) | ||
14 | |||
15 | const accountsInvolved = await VideoChannelShareModel.loadAccountsByShare(videoChannel.id, t) | ||
16 | accountsInvolved.push(byAccount) | ||
17 | |||
18 | return broadcastToFollowers(data, byAccount, accountsInvolved, t) | ||
19 | } | ||
20 | |||
21 | async function sendDeleteVideo (video: VideoModel, t: Transaction) { | 8 | async function sendDeleteVideo (video: VideoModel, t: Transaction) { |
22 | const byAccount = video.VideoChannel.Account | 9 | const byActor = video.VideoChannel.Account.Actor |
23 | 10 | ||
24 | const data = deleteActivityData(video.url, byAccount) | 11 | const data = deleteActivityData(video.url, byActor) |
25 | 12 | ||
26 | const accountsInvolved = await VideoShareModel.loadAccountsByShare(video.id, t) | 13 | const actorsInvolved = await VideoShareModel.loadActorsByShare(video.id, t) |
27 | accountsInvolved.push(byAccount) | 14 | actorsInvolved.push(byActor) |
28 | 15 | ||
29 | return broadcastToFollowers(data, byAccount, accountsInvolved, t) | 16 | return broadcastToFollowers(data, byActor, actorsInvolved, t) |
30 | } | 17 | } |
31 | 18 | ||
32 | async function sendDeleteAccount (account: AccountModel, t: Transaction) { | 19 | async function sendDeleteActor (byActor: ActorModel, t: Transaction) { |
33 | const data = deleteActivityData(account.url, account) | 20 | const data = deleteActivityData(byActor.url, byActor) |
34 | 21 | ||
35 | return broadcastToFollowers(data, account, [ account ], t) | 22 | return broadcastToFollowers(data, byActor, [ byActor ], t) |
36 | } | 23 | } |
37 | 24 | ||
38 | // --------------------------------------------------------------------------- | 25 | // --------------------------------------------------------------------------- |
39 | 26 | ||
40 | export { | 27 | export { |
41 | sendDeleteVideoChannel, | ||
42 | sendDeleteVideo, | 28 | sendDeleteVideo, |
43 | sendDeleteAccount | 29 | sendDeleteActor |
44 | } | 30 | } |
45 | 31 | ||
46 | // --------------------------------------------------------------------------- | 32 | // --------------------------------------------------------------------------- |
47 | 33 | ||
48 | function deleteActivityData (url: string, byAccount: AccountModel): ActivityDelete { | 34 | function deleteActivityData (url: string, byActor: ActorModel): ActivityDelete { |
49 | return { | 35 | return { |
50 | type: 'Delete', | 36 | type: 'Delete', |
51 | id: url, | 37 | id: url, |
52 | actor: byAccount.url | 38 | actor: byActor.url |
53 | } | 39 | } |
54 | } | 40 | } |