From 6cb556449064278bdcb1a54a7b980c2e7bc735f0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 20 Mar 2020 14:43:12 +0100 Subject: Fix add comment in threads with deleted comments --- .../videos/+video-watch/comment/video-comment-add.component.ts | 2 +- .../app/videos/+video-watch/comment/video-comment.component.ts | 9 +++++++-- .../app/videos/+video-watch/comment/video-comments.component.ts | 2 +- server/lib/activitypub/audience.ts | 2 ++ server/lib/activitypub/send/send-create.ts | 3 ++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index 5784efcdf..0f7c19765 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts @@ -57,7 +57,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { if (this.parentComment) { const mentions = this.parentComments - .filter(c => c.account.id !== this.user.account.id) // Don't add mention of ourselves + .filter(c => c.account && c.account.id !== this.user.account.id) // Don't add mention of ourselves .map(c => '@' + c.by) const mentionsSet = new Set(mentions) diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts index f7eca45fd..1313b6585 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts @@ -125,7 +125,12 @@ export class VideoCommentComponent implements OnInit, OnChanges { const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true) this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html) this.newParentComments = this.parentComments.concat([ this.comment ]) - this.commentAccount = new Account(this.comment.account) - this.getUserIfNeeded(this.commentAccount) + + if (this.comment.account) { + this.commentAccount = new Account(this.comment.account) + this.getUserIfNeeded(this.commentAccount) + } else { + this.comment.account = null + } } } diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index f2bb5c464..f1408effb 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts @@ -183,7 +183,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { // Mark the comment as deleted this.softDeleteComment(commentToDelete) - if (this.highlightedThread.id === commentToDelete.id) this.highlightedThread = undefined + if (this.highlightedThread?.id === commentToDelete.id) this.highlightedThread = undefined }, err => this.notifier.error(err.message) diff --git a/server/lib/activitypub/audience.ts b/server/lib/activitypub/audience.ts index 9933ae2b5..551d04ae3 100644 --- a/server/lib/activitypub/audience.ts +++ b/server/lib/activitypub/audience.ts @@ -32,6 +32,8 @@ function getVideoCommentAudience ( // Send to actors we reply to for (const parentComment of threadParentComments) { + if (parentComment.isDeleted()) continue + cc.push(parentComment.Account.Actor.url) } diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index 8bdcf6417..e2fa061e8 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts @@ -80,7 +80,8 @@ async function sendCreateVideoComment (comment: MCommentOwnerVideo, t: Transacti // Add the actor that commented too actorsInvolvedInComment.push(byActor) - const parentsCommentActors = threadParentComments.map(c => c.Account.Actor) + const parentsCommentActors = threadParentComments.filter(c => !c.isDeleted()) + .map(c => c.Account.Actor) let audience: ActivityAudience if (isOrigin) { -- cgit v1.2.3