Skip to content

Commit

Permalink
Fix duplicate reply notification emails
Browse files Browse the repository at this point in the history
  • Loading branch information
Sentynel committed Sep 11, 2021
1 parent 6a09963 commit 342164e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/server/services/notifications/categories/reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from "coral-server/events";
import { mapErrorsToNull } from "coral-server/helpers/dataloader";
import { hasPublishedStatus } from "coral-server/models/comment";
import { PUBLISHED_STATUSES } from "coral-server/models/comment/constants";
import { getStoryTitle, getURLWithCommentID } from "coral-server/models/story";
import { IgnoredUser } from "coral-server/models/user";

Expand All @@ -22,6 +23,14 @@ export const reply: NotificationCategory<Payloads> = {
return null;
}

// If the comment was already in a published state, don't notify again
if (
"oldStatus" in input.data &&
PUBLISHED_STATUSES.includes(input.data.oldStatus)
) {
return null;
}

// TODO: evaluate storing a history of comment statuses so we can ensure we don't double send.

// Check to see if this is a reply to an existing comment.
Expand Down

0 comments on commit 342164e

Please sign in to comment.