aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-27 10:26:52 +0200
committerChocobozzz <me@florianbigard.com>2018-03-27 11:11:15 +0200
commit73c0809326670867642f8a36f68d8564e0e406b5 (patch)
treeb2849106a252f8b2108318d90767dcb747d9dd6c /server/lib/activitypub/process
parent649f0334e0673a28d1674aa82de29326fa3cdb63 (diff)
downloadPeerTube-73c0809326670867642f8a36f68d8564e0e406b5.tar.gz
PeerTube-73c0809326670867642f8a36f68d8564e0e406b5.tar.zst
PeerTube-73c0809326670867642f8a36f68d8564e0e406b5.zip
Fix delete comment federation
Diffstat (limited to 'server/lib/activitypub/process')
-rw-r--r--server/lib/activitypub/process/process-delete.ts15
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'
8import { VideoChannelModel } from '../../../models/video/video-channel' 8import { VideoChannelModel } from '../../../models/video/video-channel'
9import { VideoCommentModel } from '../../../models/video/video-comment' 9import { VideoCommentModel } from '../../../models/video/video-comment'
10import { getOrCreateActorAndServerAndModel } from '../actor' 10import { getOrCreateActorAndServerAndModel } from '../actor'
11import { forwardActivity } from '../send/misc'
11 12
12async function processDeleteActivity (activity: ActivityDelete) { 13async 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
119async function processDeleteVideoComment (actor: ActorModel, videoComment: VideoCommentModel) { 120async 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
128function deleteRemoteVideoComment (actor: ActorModel, videoComment: VideoCommentModel) { 129function 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}