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,016 B
JavaScript
46 lines
1,016 B
JavaScript
// utils/pendingVpPinResets.js
|
|
//
|
|
// In-memory store for pending voice portal 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 pendingVpPinResets = {
|
|
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('resetvppin:cleanup', `Expired card ${cardId} for store ${data?.storeNum || 'unknown'}`);
|
|
_store.delete(cardId);
|
|
}
|
|
}
|
|
}, SWEEP_INTERVAL_MS);
|
|
|
|
sweepHandle.unref?.();
|