]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/lib/activitypub/send/send-delete.ts
Use RsaSignature2017
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-delete.ts
... / ...
CommitLineData
1import { Transaction } from 'sequelize'
2import { ActivityDelete } from '../../../../shared/models/activitypub'
3import { ActorModel } from '../../../models/activitypub/actor'
4import { VideoModel } from '../../../models/video/video'
5import { VideoShareModel } from '../../../models/video/video-share'
6import { broadcastToFollowers } from './misc'
7
8async 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
19async 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
27export {
28 sendDeleteVideo,
29 sendDeleteActor
30}
31
32// ---------------------------------------------------------------------------
33
34function deleteActivityData (url: string, byActor: ActorModel): ActivityDelete {
35 return {
36 type: 'Delete',
37 id: url,
38 actor: byActor.url
39 }
40}