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

Function roleForNewMember

server/src/slack/sync.ts:29–45  ·  view source on GitHub ↗

* Determine the role for a new org member. If the org has no admin or owner, * the first member gets 'owner' to prevent ownerless orgs.

(orgId: string)

Source from the content-addressed store, hash-verified

27 * the first member gets 'owner' to prevent ownerless orgs.
28 */
29async function roleForNewMember(orgId: string): Promise<'owner' | 'member'> {
30 try {
31 const workos = getWorkos();
32 const memberships = await workos.userManagement.listOrganizationMemberships({
33 organizationId: orgId,
34 statuses: ['active', 'inactive', 'pending'],
35 limit: 100,
36 });
37 const hasAdmin = memberships.data.some((m) => {
38 const role = m.role?.slug;
39 return role === 'admin' || role === 'owner';
40 });
41 return hasAdmin ? 'member' : 'owner';
42 } catch {
43 return 'member';
44 }
45}
46
47/**
48 * Sync all Slack users to the database

Callers 1

Calls 1

getWorkosFunction · 0.85

Tested by

no test coverage detected