diff options
Diffstat (limited to 'server/lib/activitypub/process/process-delete.ts')
-rw-r--r-- | server/lib/activitypub/process/process-delete.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts index 03eadcbfc..b58f6c04a 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/lib/activitypub/process/process-delete.ts | |||
@@ -8,6 +8,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 { VideoCommentModel } from '../../../models/video/video-comment' |
10 | import { getOrCreateActorAndServerAndModel } from '../actor' | 10 | import { getOrCreateActorAndServerAndModel } from '../actor' |
11 | import { forwardActivity } from '../send/misc' | ||
11 | 12 | ||
12 | async function processDeleteActivity (activity: ActivityDelete) { | 13 | async function processDeleteActivity (activity: ActivityDelete) { |
13 | const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id | 14 | const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id |
@@ -33,7 +34,7 @@ async function processDeleteActivity (activity: ActivityDelete) { | |||
33 | { | 34 | { |
34 | const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(objectUrl) | 35 | const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(objectUrl) |
35 | if (videoCommentInstance) { | 36 | if (videoCommentInstance) { |
36 | return processDeleteVideoComment(actor, videoCommentInstance) | 37 | return processDeleteVideoComment(actor, videoCommentInstance, activity) |
37 | } | 38 | } |
38 | } | 39 | } |
39 | 40 | ||
@@ -116,21 +117,27 @@ async function deleteRemoteVideoChannel (videoChannelToRemove: VideoChannelModel | |||
116 | logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.Actor.uuid) | 117 | logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.Actor.uuid) |
117 | } | 118 | } |
118 | 119 | ||
119 | async function processDeleteVideoComment (actor: ActorModel, videoComment: VideoCommentModel) { | 120 | async function processDeleteVideoComment (byActor: ActorModel, videoComment: VideoCommentModel, activity: ActivityDelete) { |
120 | const options = { | 121 | const options = { |
121 | arguments: [ actor, videoComment ], | 122 | arguments: [ byActor, videoComment, activity ], |
122 | errorMessage: 'Cannot remove the remote video comment with many retries.' | 123 | errorMessage: 'Cannot remove the remote video comment with many retries.' |
123 | } | 124 | } |
124 | 125 | ||
125 | await retryTransactionWrapper(deleteRemoteVideoComment, options) | 126 | await retryTransactionWrapper(deleteRemoteVideoComment, options) |
126 | } | 127 | } |
127 | 128 | ||
128 | function deleteRemoteVideoComment (actor: ActorModel, videoComment: VideoCommentModel) { | 129 | function deleteRemoteVideoComment (byActor: ActorModel, videoComment: VideoCommentModel, activity: ActivityDelete) { |
129 | logger.debug('Removing remote video comment "%s".', videoComment.url) | 130 | logger.debug('Removing remote video comment "%s".', videoComment.url) |
130 | 131 | ||
131 | return sequelizeTypescript.transaction(async t => { | 132 | return sequelizeTypescript.transaction(async t => { |
132 | await videoComment.destroy({ transaction: t }) | 133 | await videoComment.destroy({ transaction: t }) |
133 | 134 | ||
135 | if (videoComment.Video.isOwned()) { | ||
136 | // Don't resend the activity to the sender | ||
137 | const exceptions = [ byActor ] | ||
138 | await forwardActivity(activity, t, exceptions) | ||
139 | } | ||
140 | |||
134 | logger.info('Remote video comment %s removed.', videoComment.url) | 141 | logger.info('Remote video comment %s removed.', videoComment.url) |
135 | }) | 142 | }) |
136 | } | 143 | } |