diff --git a/client/src/core/client/stream/tabs/Notifications/NotificationContainer.tsx b/client/src/core/client/stream/tabs/Notifications/NotificationContainer.tsx index 917ea18bb0..a715701db3 100644 --- a/client/src/core/client/stream/tabs/Notifications/NotificationContainer.tsx +++ b/client/src/core/client/stream/tabs/Notifications/NotificationContainer.tsx @@ -48,6 +48,9 @@ const getIcon = (type: NOTIFICATION_TYPE | null): ComponentType => { if (type === GQLNOTIFICATION_TYPE.COMMENT_APPROVED) { return CheckCircleIcon; } + if (type === GQLNOTIFICATION_TYPE.PREVIOUSLY_REJECTED_COMMENT_APPROVED) { + return CheckCircleIcon; + } if (type === GQLNOTIFICATION_TYPE.COMMENT_FEATURED) { return RatingStarRibbonIcon; } @@ -83,6 +86,13 @@ const getTitle = ( "Your comment has been published" ); } + if (type === GQLNOTIFICATION_TYPE.PREVIOUSLY_REJECTED_COMMENT_APPROVED) { + return getMessage( + bundles, + "notifications-yourPreviouslyRejectedCommentHasBeenApproved", + "Your comment was previously rejected. It has now been approved." + ); + } if (type === GQLNOTIFICATION_TYPE.COMMENT_FEATURED) { return getMessage( bundles, @@ -200,7 +210,9 @@ const NotificationContainer: FunctionComponent = ({ {(type === GQLNOTIFICATION_TYPE.REPLY || type === GQLNOTIFICATION_TYPE.REPLY_STAFF || type === GQLNOTIFICATION_TYPE.COMMENT_FEATURED || - type === GQLNOTIFICATION_TYPE.COMMENT_APPROVED) && ( + type === GQLNOTIFICATION_TYPE.COMMENT_APPROVED || + type === + GQLNOTIFICATION_TYPE.PREVIOUSLY_REJECTED_COMMENT_APPROVED) && ( , + now = new Date() + ) { + const notification = await createNotification(this.mongo, { + id: uuid(), + tenantID, + type, + createdAt: now, + ownerID: targetUserID, + commentID: comment.id, + commentStatus: comment.status, + }); + + return notification; + } + private async createRejectCommentNotification( tenantID: string, type: GQLNOTIFICATION_TYPE, diff --git a/server/src/core/server/stacks/approveComment.ts b/server/src/core/server/stacks/approveComment.ts index 150d9a35cf..51e4dc9a09 100644 --- a/server/src/core/server/stacks/approveComment.ts +++ b/server/src/core/server/stacks/approveComment.ts @@ -106,6 +106,19 @@ const approveComment = async ( }); } + // create notification if dsa enabled upon approval of previously rejected comment + if ( + tenant.dsa?.enabled && + previousComment?.status === GQLCOMMENT_STATUS.REJECTED + ) { + await notifications.create(tenant.id, tenant.locale, { + targetUserID: result.after.authorID!, + comment: result.after, + previousStatus: result.before.status, + type: GQLNOTIFICATION_TYPE.PREVIOUSLY_REJECTED_COMMENT_APPROVED, + }); + } + // if comment was previously rejected, system withheld, or in pre-mod, // and there is a reply notification for it, increment the notificationCount // for that notification's owner since it was decremented upon original