(job)
| 1000 | const entry = handledCommands.get(key); |
| 1001 | if (!entry || now() - entry.time >= COMMAND_DEDUPE_MS) { |
| 1002 | handledCommands.delete(key); |
| 1003 | return false; |
| 1004 | } |
| 1005 | if (entry.pending <= 1) |
| 1006 | handledCommands.delete(key); |
| 1007 | else |
| 1008 | handledCommands.set(key, { time: entry.time, pending: entry.pending - 1 }); |
| 1009 | return true; |
| 1010 | } |
| 1011 | function hasHandledCommandEvent(sessionID, messageID) { |
| 1012 | return handledCommandEvents.has(commandEventKey(sessionID, messageID)); |
| 1013 | } |
| 1014 | function markHandledCommandEvent(sessionID, messageID) { |
| 1015 | handledCommandEvents.set(commandEventKey(sessionID, messageID), now()); |
| 1016 | } |
| 1017 | function forgetHandledCommandEvent(sessionID, messageID) { |
| 1018 | handledCommandEvents.delete(commandEventKey(sessionID, messageID)); |
| 1019 | } |
| 1020 | function clearCommandLifecycle(sessionID) { |
| 1021 | const prefix = `${sessionID}:`; |
| 1022 | for (const key of handledCommands.keys()) |
| 1023 | if (key.startsWith(prefix)) |
| 1024 | handledCommands.delete(key); |
| 1025 | for (const key of handledCommandEvents.keys()) |
| 1026 | if (key.startsWith(prefix)) |
| 1027 | handledCommandEvents.delete(key); |
| 1028 | } |
| 1029 | function commandName(name) { |
| 1030 | return String(name || ""); |
| 1031 | } |
no test coverage detected