aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send/send-delete.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-14 17:38:41 +0100
committerChocobozzz <me@florianbigard.com>2017-12-19 10:53:16 +0100
commit50d6de9c286abcb34ff4234d56d9cbb803db7665 (patch)
treef1732b27edcd05c7877a8358b8312f1e38c287ed /server/lib/activitypub/send/send-delete.ts
parentfadf619ad61a016c1c7fc53de5a8f398a4f77519 (diff)
downloadPeerTube-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.ts38
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 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityDelete } from '../../../../shared/models/activitypub' 2import { ActivityDelete } from '../../../../shared/models/activitypub'
3import { AccountModel } from '../../../models/account/account' 3import { ActorModel } from '../../../models/activitypub/actor'
4import { VideoModel } from '../../../models/video/video' 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 { VideoShareModel } from '../../../models/video/video-share'
8import { broadcastToFollowers } from './misc' 6import { broadcastToFollowers } from './misc'
9 7
10async 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
21async function sendDeleteVideo (video: VideoModel, t: Transaction) { 8async 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
32async function sendDeleteAccount (account: AccountModel, t: Transaction) { 19async 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
40export { 27export {
41 sendDeleteVideoChannel,
42 sendDeleteVideo, 28 sendDeleteVideo,
43 sendDeleteAccount 29 sendDeleteActor
44} 30}
45 31
46// --------------------------------------------------------------------------- 32// ---------------------------------------------------------------------------
47 33
48function deleteActivityData (url: string, byAccount: AccountModel): ActivityDelete { 34function 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}