]>
Commit | Line | Data |
---|---|---|
54141398 | 1 | import { Transaction } from 'sequelize' |
3fd3ab2d | 2 | import { ActivityDelete } from '../../../../shared/models/activitypub' |
50d6de9c | 3 | import { ActorModel } from '../../../models/activitypub/actor' |
3fd3ab2d | 4 | import { VideoModel } from '../../../models/video/video' |
4cb6d457 | 5 | import { VideoCommentModel } from '../../../models/video/video-comment' |
3fd3ab2d | 6 | import { VideoShareModel } from '../../../models/video/video-share' |
c3badc81 | 7 | import { getDeleteActivityPubUrl } from '../url' |
54141398 C |
8 | import { broadcastToFollowers } from './misc' |
9 | ||
3fd3ab2d | 10 | async function sendDeleteVideo (video: VideoModel, t: Transaction) { |
c3badc81 | 11 | const url = getDeleteActivityPubUrl(video.url) |
50d6de9c | 12 | const byActor = video.VideoChannel.Account.Actor |
54141398 | 13 | |
c3badc81 | 14 | const data = deleteActivityData(url, video.url, byActor) |
54141398 | 15 | |
50d6de9c C |
16 | const actorsInvolved = await VideoShareModel.loadActorsByShare(video.id, t) |
17 | actorsInvolved.push(byActor) | |
54141398 | 18 | |
50d6de9c | 19 | return broadcastToFollowers(data, byActor, actorsInvolved, t) |
54141398 C |
20 | } |
21 | ||
50d6de9c | 22 | async function sendDeleteActor (byActor: ActorModel, t: Transaction) { |
c3badc81 C |
23 | const url = getDeleteActivityPubUrl(byActor.url) |
24 | const data = deleteActivityData(url, byActor.url, byActor) | |
54141398 | 25 | |
f05a1c30 C |
26 | const actorsInvolved = await VideoShareModel.loadActorsByVideoOwner(byActor.id, t) |
27 | actorsInvolved.push(byActor) | |
28 | ||
29 | return broadcastToFollowers(data, byActor, actorsInvolved, t) | |
54141398 C |
30 | } |
31 | ||
4cb6d457 | 32 | async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Transaction) { |
c3badc81 | 33 | const url = getDeleteActivityPubUrl(videoComment.url) |
4cb6d457 | 34 | |
c3badc81 C |
35 | const byActor = videoComment.Account.Actor |
36 | const data = deleteActivityData(url, videoComment.url, byActor) | |
4cb6d457 C |
37 | |
38 | const actorsInvolved = await VideoShareModel.loadActorsByShare(videoComment.Video.id, t) | |
39 | actorsInvolved.push(videoComment.Video.VideoChannel.Account.Actor) | |
40 | actorsInvolved.push(byActor) | |
41 | ||
42 | return broadcastToFollowers(data, byActor, actorsInvolved, t) | |
43 | } | |
44 | ||
54141398 C |
45 | // --------------------------------------------------------------------------- |
46 | ||
47 | export { | |
54141398 | 48 | sendDeleteVideo, |
4cb6d457 C |
49 | sendDeleteActor, |
50 | sendDeleteVideoComment | |
54141398 C |
51 | } |
52 | ||
53 | // --------------------------------------------------------------------------- | |
54 | ||
c3badc81 | 55 | function deleteActivityData (url: string, object: string, byActor: ActorModel): ActivityDelete { |
3fd3ab2d | 56 | return { |
54141398 C |
57 | type: 'Delete', |
58 | id: url, | |
c3badc81 C |
59 | actor: byActor.url, |
60 | object | |
54141398 | 61 | } |
54141398 | 62 | } |