fix: address review comments on incident comment notifications

- Import GetAllSiteData directly from siteDataController instead of the
  controller barrel, which re-exports incidentController and creates a
  circular import (risk of partially-initialized modules at runtime).
- Pass a stable per-comment deduplication id to subscriberQueue.push so a
  retried/double push notifies once; without it the queue falls back to a
  Date.now()-suffixed id that never deduplicates.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Raj Nandan Sharma
2026-07-07 22:53:58 +05:30
parent f2f58e6b87
commit e7a5b1df39
@@ -18,7 +18,7 @@ import type {
import GC from "../../global-constants.js";
import { getUnixTime, differenceInSeconds } from "date-fns";
import { siteDataToVariables } from "../notification/notification_utils.js";
import { GetAllSiteData } from "./controller.js";
import { GetAllSiteData } from "./siteDataController.js";
import subscriberQueue from "../queues/subscriberQueue.js";
import mdToHTML from "../../marked.js";
import type { SubscriptionVariableMap } from "../notification/types.js";
@@ -443,7 +443,11 @@ const notifySubscribersOfComment = async (
update_id: String(comment.id),
event_type: "incidents",
};
await subscriberQueue.push(variables);
// Stable dedup id per comment so a retried/double push notifies once — without
// it subscriberQueue falls back to a Date.now()-suffixed id that never dedupes.
await subscriberQueue.push(variables, {
deduplication: { id: `subscriber-incidents-${comment.id}` },
});
} catch (err) {
console.error(`Error sending subscriber notification for incident ${incident.id}:`, err);
}