aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-03-20 14:43:12 +0100
committerChocobozzz <me@florianbigard.com>2020-03-20 14:43:12 +0100
commit6cb556449064278bdcb1a54a7b980c2e7bc735f0 (patch)
treea3d72e90cfc6074a00cd04d5197dded12260b69e
parent5db4545cd2af2298ef6514dde2c36edc98ef5e33 (diff)
downloadPeerTube-6cb556449064278bdcb1a54a7b980c2e7bc735f0.tar.gz
PeerTube-6cb556449064278bdcb1a54a7b980c2e7bc735f0.tar.zst
PeerTube-6cb556449064278bdcb1a54a7b980c2e7bc735f0.zip
Fix add comment in threads with deleted comments
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.ts2
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.ts9
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.ts2
-rw-r--r--server/lib/activitypub/audience.ts2
-rw-r--r--server/lib/activitypub/send/send-create.ts3
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 {
57 57
58 if (this.parentComment) { 58 if (this.parentComment) {
59 const mentions = this.parentComments 59 const mentions = this.parentComments
60 .filter(c => c.account.id !== this.user.account.id) // Don't add mention of ourselves 60 .filter(c => c.account && c.account.id !== this.user.account.id) // Don't add mention of ourselves
61 .map(c => '@' + c.by) 61 .map(c => '@' + c.by)
62 62
63 const mentionsSet = new Set(mentions) 63 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 {
125 const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true) 125 const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true)
126 this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html) 126 this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html)
127 this.newParentComments = this.parentComments.concat([ this.comment ]) 127 this.newParentComments = this.parentComments.concat([ this.comment ])
128 this.commentAccount = new Account(this.comment.account) 128
129 this.getUserIfNeeded(this.commentAccount) 129 if (this.comment.account) {
130 this.commentAccount = new Account(this.comment.account)
131 this.getUserIfNeeded(this.commentAccount)
132 } else {
133 this.comment.account = null
134 }
130 } 135 }
131} 136}
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 {
183 // Mark the comment as deleted 183 // Mark the comment as deleted
184 this.softDeleteComment(commentToDelete) 184 this.softDeleteComment(commentToDelete)
185 185
186 if (this.highlightedThread.id === commentToDelete.id) this.highlightedThread = undefined 186 if (this.highlightedThread?.id === commentToDelete.id) this.highlightedThread = undefined
187 }, 187 },
188 188
189 err => this.notifier.error(err.message) 189 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 (
32 32
33 // Send to actors we reply to 33 // Send to actors we reply to
34 for (const parentComment of threadParentComments) { 34 for (const parentComment of threadParentComments) {
35 if (parentComment.isDeleted()) continue
36
35 cc.push(parentComment.Account.Actor.url) 37 cc.push(parentComment.Account.Actor.url)
36 } 38 }
37 39
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
80 // Add the actor that commented too 80 // Add the actor that commented too
81 actorsInvolvedInComment.push(byActor) 81 actorsInvolvedInComment.push(byActor)
82 82
83 const parentsCommentActors = threadParentComments.map(c => c.Account.Actor) 83 const parentsCommentActors = threadParentComments.filter(c => !c.isDeleted())
84 .map(c => c.Account.Actor)
84 85
85 let audience: ActivityAudience 86 let audience: ActivityAudience
86 if (isOrigin) { 87 if (isOrigin) {