]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/activitypub/send/send-delete.ts
Begin moving video channel to actor
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-delete.ts
1 import { Transaction } from 'sequelize'
2 import { ActivityDelete } from '../../../../shared/models/activitypub'
3 import { ActorModel } from '../../../models/activitypub/actor'
4 import { VideoModel } from '../../../models/video/video'
5 import { VideoShareModel } from '../../../models/video/video-share'
6 import { broadcastToFollowers } from './misc'
7
8 async function sendDeleteVideo (video: VideoModel, t: Transaction) {
9 const byActor = video.VideoChannel.Account.Actor
10
11 const data = deleteActivityData(video.url, byActor)
12
13 const actorsInvolved = await VideoShareModel.loadActorsByShare(video.id, t)
14 actorsInvolved.push(byActor)
15
16 return broadcastToFollowers(data, byActor, actorsInvolved, t)
17 }
18
19 async function sendDeleteActor (byActor: ActorModel, t: Transaction) {
20 const data = deleteActivityData(byActor.url, byActor)
21
22 return broadcastToFollowers(data, byActor, [ byActor ], t)
23 }
24
25 // ---------------------------------------------------------------------------
26
27 export {
28 sendDeleteVideo,
29 sendDeleteActor
30 }
31
32 // ---------------------------------------------------------------------------
33
34 function deleteActivityData (url: string, byActor: ActorModel): ActivityDelete {
35 return {
36 type: 'Delete',
37 id: url,
38 actor: byActor.url
39 }
40 }