Some checks failed
CI / verify (push) Has been cancelled
New /provisionPhone <storeNumber> command manages the store user's wired desk phones via the same card pattern as /provisionDect: multi-select checkbox list that doubles as the display, MACs render as AA:BB:CC:DD:EE:FF, model dropdown for add (defaults to 7841), side-by-side Add / Remove-checked actions, and every removal goes through an explicit confirm card. Adds are idempotent (MACs already registered are skipped) and bulk MAC input is supported. DECT handsets are filtered out of the display so /provisionPhone and /provisionDect coexist cleanly on the same store user without overlapping responsibilities. Refactors: - Extract MAC helpers (normalize/format/display) to src/utils/mac.js so both DECT and wired-phone flows share one implementation. dect.js re-exports for backward compat with existing consumers. - Add parseEmailArg helper; migrate /userInfo to use it. Tests: pure-logic coverage for WIRED_PHONE_MODELS, isSupportedWiredModel, filterWiredPhones (DECT/model filter), and parseEmailArg. Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
import { logger } from '../logger.js';
|
|
import { buildUserInfoCard } from '../cards/userInfoCard.js';
|
|
import { parseEmailArg } from './helpers.js';
|
|
|
|
export function register(framework) {
|
|
framework.hears(
|
|
/\/userInfo/i,
|
|
async (bot, trigger) => {
|
|
logger.info(`${trigger.person.displayName} ran the userInfo command.`);
|
|
const email = parseEmailArg(trigger);
|
|
if (!email) {
|
|
bot.say(
|
|
'Usage: `/userInfo <email>` — e.g. `/userInfo mcqueenj@ae.com`. ' +
|
|
'The argument must look like an email (`local@domain.tld`).',
|
|
);
|
|
return;
|
|
}
|
|
try {
|
|
const card = await buildUserInfoCard(email);
|
|
bot.sendCard(card, 'Use a proper client...');
|
|
} catch (error) {
|
|
logger.error('userInfo command failed:', error);
|
|
bot.say(`Error finding user information: ${error.message}`);
|
|
}
|
|
},
|
|
'**/userInfo** <userEmail> - Shows user information',
|
|
);
|
|
}
|