feature/IO-3492-FCM-Queue-For-Notifications: Finalize

This commit is contained in:
Dave
2026-01-05 18:42:40 -05:00
parent 4cdc15f70b
commit 00bf5977ae
5 changed files with 170 additions and 35 deletions

View File

@@ -168,6 +168,7 @@ const loadAppQueue = async ({ pubClient, logger, redisHelpers, ioRedis }) => {
// Collect notifications by recipientKey
const notificationsByRecipient = new Map(); // rk => parsed notifications array
const listKeysToDelete = []; // delete only after successful insert+emit
for (const rk of recipientKeys) {
const [user, bodyShopId] = rk.split(":");
@@ -188,14 +189,17 @@ const loadAppQueue = async ({ pubClient, logger, redisHelpers, ioRedis }) => {
if (parsed.length) {
notificationsByRecipient.set(rk, parsed);
}
// Cleanup list key after reading
await pubClient.del(lk);
// IMPORTANT: do NOT delete list yet; only delete after successful insert+emit
listKeysToDelete.push(lk);
}
}
if (!notificationsByRecipient.size) {
devDebugLogger(`No notifications found in lists for jobId ${jobId}, nothing to insert/emit.`);
if (listKeysToDelete.length) {
await pubClient.del(...listKeysToDelete);
}
await pubClient.del(rkSet);
await pubClient.del(assocHash);
await pubClient.del(consolidateFlagKey(jobId));