wbxcallprov/scripts/fixStorePhones.js
jmcqueen 93b060bc8b Modernize bot to Node.js 22 with modular architecture and remote SIW agent
- Refactor monolithic index.js (2646 lines) into src/{webex,integrations,
  cards,flows,commands,services} modules; replace node-fetch/form-data
  with native fetch/FormData; move all secrets to .env via dotenv
- Add dockerized remote SIW agent (docker/remote-agent/) with cross-arch
  buildx packaging (arm64 Mac -> linux/amd64), idempotent install.sh
  deploy bundle, and docker-free ZIP inspector for arch verification
- Bot hosts a WebSocket server; agent proxies SIW requests with a
  per-request insecure:true flag, replacing the process-wide
  NODE_TLS_REJECT_UNAUTHORIZED bypass
- Add ESLint flat config + Prettier, rewrite Dockerfile as non-root
  multi-stage node:22-alpine build, README covering setup / deploy /
  remote agent workflow
- Fix parseStoreArg to read trigger.prompt correctly (was indexing past
  the framework's post-match slice); register /help as regex (string
  matcher only compares the first token); switch catch-all to /.+/
  (previous /.*/gim was stateful due to the g flag); remove
  /fixDisplayNames command and its flow/card

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 14:48:51 -04:00

36 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
/**
* One-shot cleanup for store users: normalize licensing and pin the default
* meeting site. Replaces the legacy phoneFix.js.
*/
import { getAllUsers, setDefaultMeetingSite } from '../src/webex/users.js';
import { normalizeStoreUserLicenses } from '../src/webex/licensing.js';
import { DEFAULT_DEFAULT_MEETING_SITE } from '../src/constants.js';
import { logger } from '../src/logger.js';
async function main() {
logger.info('Fetching all Webex users...');
const users = await getAllUsers();
const storeUsers = users.filter((u) => u.firstName === 'Store');
logger.info(`Found ${storeUsers.length} store users to normalize.`);
for (const user of storeUsers) {
try {
await normalizeStoreUserLicenses(user);
logger.info(`${user.displayName} license normalized.`);
} catch (error) {
logger.error(`Error updating license for ${user.displayName}:`, error);
}
try {
await setDefaultMeetingSite(user.emails[0], DEFAULT_DEFAULT_MEETING_SITE);
logger.info(`${user.displayName} default site updated.`);
} catch (error) {
logger.error(`Error updating default site for ${user.displayName}:`, error);
}
}
}
main().catch((error) => {
logger.error('fixStorePhones failed:', error);
process.exit(1);
});