(userId: string)
| 490 | * - they are an active member of a working group |
| 491 | */ |
| 492 | export async function getUserSeatType(userId: string): Promise<SeatType | null> { |
| 493 | const pool = getPool(); |
| 494 | const result = await pool.query<{ is_contributor: boolean }>( |
| 495 | `SELECT ( |
| 496 | EXISTS (SELECT 1 FROM organization_memberships WHERE workos_user_id = $1 AND seat_type = 'contributor') |
| 497 | OR EXISTS (SELECT 1 FROM slack_user_mappings WHERE workos_user_id = $1 AND mapping_status = 'mapped') |
| 498 | OR EXISTS (SELECT 1 FROM working_group_memberships WHERE workos_user_id = $1 AND status = 'active') |
| 499 | ) as is_contributor |
| 500 | FROM organization_memberships WHERE workos_user_id = $1 LIMIT 1`, |
| 501 | [userId] |
| 502 | ); |
| 503 | if (result.rows.length === 0) return null; |
| 504 | return result.rows[0]?.is_contributor ? 'contributor' : 'community_only'; |
| 505 | } |
| 506 | |
| 507 | // ==================== Seat Warning Threshold Management ==================== |
| 508 |
no test coverage detected