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