MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / buildAaoEmailToUserIdMap

Function buildAaoEmailToUserIdMap

server/src/slack/sync.ts:581–593  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

579 * Uses the local organization_memberships table (synced from WorkOS via webhooks).
580 */
581export async function buildAaoEmailToUserIdMap(): Promise<Map<string, string>> {
582 const pool = getPool();
583 const aaoEmailToUserId = new Map<string, string>();
584 const result = await pool.query<{ email: string; workos_user_id: string }>(`
585 SELECT DISTINCT email, workos_user_id
586 FROM organization_memberships
587 WHERE email IS NOT NULL
588 `);
589 for (const row of result.rows) {
590 aaoEmailToUserId.set(row.email.toLowerCase(), row.workos_user_id);
591 }
592 return aaoEmailToUserId;
593}
594
595/**
596 * Check if a user should be assigned to an organization based on their email domain.

Callers 2

createAdminSlackRouterFunction · 0.85

Calls 2

getPoolFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected