diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/process/process-delete.ts | 33 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-delete.ts | 16 |
2 files changed, 45 insertions, 4 deletions
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts index 523a31822..604570e74 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/lib/activitypub/process/process-delete.ts | |||
@@ -6,6 +6,7 @@ import { AccountModel } from '../../../models/account/account' | |||
6 | import { ActorModel } from '../../../models/activitypub/actor' | 6 | import { ActorModel } from '../../../models/activitypub/actor' |
7 | import { VideoModel } from '../../../models/video/video' | 7 | import { VideoModel } from '../../../models/video/video' |
8 | import { VideoChannelModel } from '../../../models/video/video-channel' | 8 | import { VideoChannelModel } from '../../../models/video/video-channel' |
9 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
9 | import { getOrCreateActorAndServerAndModel } from '../actor' | 10 | import { getOrCreateActorAndServerAndModel } from '../actor' |
10 | 11 | ||
11 | async function processDeleteActivity (activity: ActivityDelete) { | 12 | async function processDeleteActivity (activity: ActivityDelete) { |
@@ -24,9 +25,16 @@ async function processDeleteActivity (activity: ActivityDelete) { | |||
24 | } | 25 | } |
25 | 26 | ||
26 | { | 27 | { |
27 | let videoObject = await VideoModel.loadByUrlAndPopulateAccount(activity.id) | 28 | const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(activity.id) |
28 | if (videoObject !== undefined) { | 29 | if (videoCommentInstance) { |
29 | return processDeleteVideo(actor, videoObject) | 30 | return processDeleteVideoComment(actor, videoCommentInstance) |
31 | } | ||
32 | } | ||
33 | |||
34 | { | ||
35 | const videoInstance = await VideoModel.loadByUrlAndPopulateAccount(activity.id) | ||
36 | if (videoInstance) { | ||
37 | return processDeleteVideo(actor, videoInstance) | ||
30 | } | 38 | } |
31 | } | 39 | } |
32 | 40 | ||
@@ -101,3 +109,22 @@ async function deleteRemoteVideoChannel (videoChannelToRemove: VideoChannelModel | |||
101 | 109 | ||
102 | logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.Actor.uuid) | 110 | logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.Actor.uuid) |
103 | } | 111 | } |
112 | |||
113 | async function processDeleteVideoComment (actor: ActorModel, videoComment: VideoCommentModel) { | ||
114 | const options = { | ||
115 | arguments: [ actor, videoComment ], | ||
116 | errorMessage: 'Cannot remove the remote video comment with many retries.' | ||
117 | } | ||
118 | |||
119 | await retryTransactionWrapper(deleteRemoteVideoComment, options) | ||
120 | } | ||
121 | |||
122 | function deleteRemoteVideoComment (actor: ActorModel, videoComment: VideoCommentModel) { | ||
123 | logger.debug('Removing remote video comment "%s".', videoComment.url) | ||
124 | |||
125 | return sequelizeTypescript.transaction(async t => { | ||
126 | await videoComment.destroy({ transaction: t }) | ||
127 | |||
128 | logger.info('Remote video comment %s removed.', videoComment.url) | ||
129 | }) | ||
130 | } | ||
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index 4bc5db77e..1ca031898 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/lib/activitypub/send/send-delete.ts | |||
@@ -2,6 +2,7 @@ import { Transaction } from 'sequelize' | |||
2 | import { ActivityDelete } from '../../../../shared/models/activitypub' | 2 | import { ActivityDelete } from '../../../../shared/models/activitypub' |
3 | import { ActorModel } from '../../../models/activitypub/actor' | 3 | import { ActorModel } from '../../../models/activitypub/actor' |
4 | import { VideoModel } from '../../../models/video/video' | 4 | import { VideoModel } from '../../../models/video/video' |
5 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
5 | import { VideoShareModel } from '../../../models/video/video-share' | 6 | import { VideoShareModel } from '../../../models/video/video-share' |
6 | import { broadcastToFollowers } from './misc' | 7 | import { broadcastToFollowers } from './misc' |
7 | 8 | ||
@@ -22,11 +23,24 @@ async function sendDeleteActor (byActor: ActorModel, t: Transaction) { | |||
22 | return broadcastToFollowers(data, byActor, [ byActor ], t) | 23 | return broadcastToFollowers(data, byActor, [ byActor ], t) |
23 | } | 24 | } |
24 | 25 | ||
26 | async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Transaction) { | ||
27 | const byActor = videoComment.Account.Actor | ||
28 | |||
29 | const data = deleteActivityData(videoComment.url, byActor) | ||
30 | |||
31 | const actorsInvolved = await VideoShareModel.loadActorsByShare(videoComment.Video.id, t) | ||
32 | actorsInvolved.push(videoComment.Video.VideoChannel.Account.Actor) | ||
33 | actorsInvolved.push(byActor) | ||
34 | |||
35 | return broadcastToFollowers(data, byActor, actorsInvolved, t) | ||
36 | } | ||
37 | |||
25 | // --------------------------------------------------------------------------- | 38 | // --------------------------------------------------------------------------- |
26 | 39 | ||
27 | export { | 40 | export { |
28 | sendDeleteVideo, | 41 | sendDeleteVideo, |
29 | sendDeleteActor | 42 | sendDeleteActor, |
43 | sendDeleteVideoComment | ||
30 | } | 44 | } |
31 | 45 | ||
32 | // --------------------------------------------------------------------------- | 46 | // --------------------------------------------------------------------------- |