Chat-only commands reset voicemail mailbox and voice portal passcodes via telephony_config_write, with extension lookup and unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1,004 B
JavaScript
46 lines
1,004 B
JavaScript
// utils/pendingVmPinResets.js
|
|
//
|
|
// In-memory store for pending voicemail PIN reset confirmation cards.
|
|
|
|
import { logger } from './logger.js';
|
|
|
|
const TTL_MS = 10 * 60 * 1000;
|
|
const SWEEP_INTERVAL_MS = 60 * 1000;
|
|
|
|
const _store = new Map();
|
|
|
|
export const pendingVmPinResets = {
|
|
set(cardId, data) {
|
|
_store.set(cardId, { ...data, timestamp: Date.now() });
|
|
return this;
|
|
},
|
|
|
|
get(cardId) {
|
|
return _store.get(cardId);
|
|
},
|
|
|
|
has(cardId) {
|
|
return _store.has(cardId);
|
|
},
|
|
|
|
delete(cardId) {
|
|
return _store.delete(cardId);
|
|
},
|
|
|
|
get size() {
|
|
return _store.size;
|
|
},
|
|
};
|
|
|
|
const sweepHandle = setInterval(() => {
|
|
const now = Date.now();
|
|
for (const [cardId, data] of _store.entries()) {
|
|
const stamped = typeof data?.timestamp === 'number' ? data.timestamp : 0;
|
|
if (now - stamped > TTL_MS) {
|
|
logger('resetvmpin:cleanup', `Expired card ${cardId} for ${data?.email || 'unknown'}`);
|
|
_store.delete(cardId);
|
|
}
|
|
}
|
|
}, SWEEP_INTERVAL_MS);
|
|
|
|
sweepHandle.unref?.();
|