Skip to content

Commit eaea177

Browse files
committed
fix(comment): only mark owner comments as read on creation
Reader comments were incorrectly marked as read, preventing the owner from tracking unread comments.
1 parent fd3c0b0 commit eaea177

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

‎apps/core/src/modules/comment/comment.service.ts‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -655,10 +655,6 @@ export class CommentService {
655655
type?: CollectionRefTypes,
656656
) {
657657
const reader = await this.assignReaderToComment()
658-
const isLoggedInComment =
659-
!!reader ||
660-
RequestContext.hasReaderIdentity() ||
661-
RequestContext.hasAdminAccess()
662658
if (reader) {
663659
this.stripReaderIdentitySnapshot(doc)
664660
this.assignAuthProviderToComment(doc)
@@ -693,7 +689,9 @@ export class CommentService {
693689

694690
const comment = (await this.commentModel.create({
695691
...doc,
696-
state: isLoggedInComment ? CommentState.Read : CommentState.Unread,
692+
state: RequestContext.hasAdminAccess()
693+
? CommentState.Read
694+
: CommentState.Unread,
697695
ref: new Types.ObjectId(id),
698696
parentCommentId: null,
699697
replyCount: 0,
@@ -747,10 +745,6 @@ export class CommentService {
747745
}
748746

749747
const reader = await this.assignReaderToComment()
750-
const isLoggedInComment =
751-
!!reader ||
752-
RequestContext.hasReaderIdentity() ||
753-
RequestContext.hasAdminAccess()
754748
if (reader) {
755749
this.stripReaderIdentitySnapshot(doc)
756750
this.assignAuthProviderToComment(doc)
@@ -761,7 +755,9 @@ export class CommentService {
761755
...doc,
762756
state:
763757
doc.state ??
764-
(isLoggedInComment ? CommentState.Read : CommentState.Unread),
758+
(RequestContext.hasAdminAccess()
759+
? CommentState.Read
760+
: CommentState.Unread),
765761
ref: this.toObjectId(parent.ref as any),
766762
refType: parent.refType,
767763
parentCommentId: parent._id,

0 commit comments

Comments
 (0)