diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-07 15:35:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-07 15:35:29 +0200 |
commit | 511765c9f86fb07d5d856decd9dbf0ec2092f4fe (patch) | |
tree | 07848a09e60e78b39aa3d22f7ba1e4915b23b02a /server/lib | |
parent | fd2ddcae8ff4eb10bf7168ac3c8801f06b37627f (diff) | |
download | PeerTube-511765c9f86fb07d5d856decd9dbf0ec2092f4fe.tar.gz PeerTube-511765c9f86fb07d5d856decd9dbf0ec2092f4fe.tar.zst PeerTube-511765c9f86fb07d5d856decd9dbf0ec2092f4fe.zip |
Remove comment federation by video owner
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/process/process-delete.ts | 6 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-delete.ts | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts index 845a7b249..9fcfd9e3a 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/lib/activitypub/process/process-delete.ts | |||
@@ -34,7 +34,7 @@ async function processDeleteActivity (options: APProcessorOptions<ActivityDelete | |||
34 | } | 34 | } |
35 | 35 | ||
36 | { | 36 | { |
37 | const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(objectUrl) | 37 | const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccountAndVideo(objectUrl) |
38 | if (videoCommentInstance) { | 38 | if (videoCommentInstance) { |
39 | return retryTransactionWrapper(processDeleteVideoComment, byActor, videoCommentInstance, activity) | 39 | return retryTransactionWrapper(processDeleteVideoComment, byActor, videoCommentInstance, activity) |
40 | } | 40 | } |
@@ -121,8 +121,8 @@ function processDeleteVideoComment (byActor: ActorModel, videoComment: VideoComm | |||
121 | logger.debug('Removing remote video comment "%s".', videoComment.url) | 121 | logger.debug('Removing remote video comment "%s".', videoComment.url) |
122 | 122 | ||
123 | return sequelizeTypescript.transaction(async t => { | 123 | return sequelizeTypescript.transaction(async t => { |
124 | if (videoComment.Account.id !== byActor.Account.id) { | 124 | if (byActor.Account.id !== videoComment.Account.id && byActor.Account.id !== videoComment.Video.VideoChannel.accountId) { |
125 | throw new Error('Account ' + byActor.url + ' does not own video comment ' + videoComment.url) | 125 | throw new Error(`Account ${byActor.url} does not own video comment ${videoComment.url} or video ${videoComment.Video.url}`) |
126 | } | 126 | } |
127 | 127 | ||
128 | await videoComment.destroy({ transaction: t }) | 128 | await videoComment.destroy({ transaction: t }) |
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index 7a1d6f0ba..6c7fb8449 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/lib/activitypub/send/send-delete.ts | |||
@@ -48,7 +48,10 @@ async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Trans | |||
48 | const isVideoOrigin = videoComment.Video.isOwned() | 48 | const isVideoOrigin = videoComment.Video.isOwned() |
49 | 49 | ||
50 | const url = getDeleteActivityPubUrl(videoComment.url) | 50 | const url = getDeleteActivityPubUrl(videoComment.url) |
51 | const byActor = videoComment.Account.Actor | 51 | const byActor = videoComment.isOwned() |
52 | ? videoComment.Account.Actor | ||
53 | : videoComment.Video.VideoChannel.Account.Actor | ||
54 | |||
52 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, t) | 55 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, t) |
53 | 56 | ||
54 | const actorsInvolvedInComment = await getActorsInvolvedInVideo(videoComment.Video, t) | 57 | const actorsInvolvedInComment = await getActorsInvolvedInVideo(videoComment.Video, t) |