feature/IO-3492-FCM-Queue-For-Notifications: Implement FCM queue and worker for notifications

This commit is contained in:
Dave
2026-01-05 12:46:09 -05:00
parent 4a7bb07345
commit 4190372b92
8 changed files with 558 additions and 156 deletions

View File

@@ -14,6 +14,7 @@ const { isEmpty, isFunction } = require("lodash");
const { getMatchingScenarios } = require("./scenarioMapper");
const { dispatchEmailsToQueue } = require("./queues/emailQueue");
const { dispatchAppsToQueue } = require("./queues/appQueue");
const { dispatchFcmsToQueue } = require("./queues/fcmQueue"); // NEW
// If true, the user who commits the action will NOT receive notifications; if false, they will.
const FILTER_SELF_FROM_WATCHERS = process.env?.FILTER_SELF_FROM_WATCHERS !== "false";
@@ -298,6 +299,16 @@ const scenarioParser = async (req, jobIdField) => {
})
);
}
const fcmsToDispatch = scenariosToDispatch.map((scenario) => scenario?.fcm);
if (!isEmpty(fcmsToDispatch)) {
dispatchFcmsToQueue({ fcmsToDispatch, logger }).catch((e) =>
logger.log("Something went wrong dispatching FCMs to the FCM Notification Queue", "error", "queue", null, {
message: e?.message,
stack: e?.stack
})
);
}
};
module.exports = scenarioParser;