Fix add comment in threads with deleted comments
authorChocobozzz <me@florianbigard.com>
Fri, 20 Mar 2020 13:43:12 +0000 (14:43 +0100)
committerChocobozzz <me@florianbigard.com>
Fri, 20 Mar 2020 13:43:12 +0000 (14:43 +0100)
client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
client/src/app/videos/+video-watch/comment/video-comment.component.ts
client/src/app/videos/+video-watch/comment/video-comments.component.ts
server/lib/activitypub/audience.ts
server/lib/activitypub/send/send-create.ts

index 5784efcdf749a939c0a91069b5b982e022385491..0f7c19765c7e1fceb89cc8df8dca1764cc7fdb25 100644 (file)
@@ -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)
index f7eca45fda269af958f507485eaa0c0efbb5b5db..1313b658534e4e5b03b1efcda274787f7918cb7d 100644 (file)
@@ -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
+    }
   }
 }
index f2bb5c4648d8996a872e52755179b0a707b1e774..f1408effb38ca34f9b903a1b9aae49a3d67302d7 100644 (file)
@@ -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)
index 9933ae2b5cd8b9176495475a74620fbf90c2d6fc..551d04ae35e3c72d7f1ce86828bcc0a62dfaf2e8 100644 (file)
@@ -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)
   }
 
index 8bdcf6417cf64f12e42d17f96b6eea21bb179a0d..e2fa061e882f033dd4abc7306221d0af63a63825 100644 (file)
@@ -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) {