( orgId: string, email: string, workosUserId: string )
| 949 | * Match a newly-joined org member to a pending expectation by email. |
| 950 | */ |
| 951 | export async function matchExpectationToUser( |
| 952 | orgId: string, |
| 953 | email: string, |
| 954 | workosUserId: string |
| 955 | ): Promise<CertExpectation | null> { |
| 956 | const result = await query<CertExpectation>( |
| 957 | `UPDATE certification_expectations |
| 958 | SET workos_user_id = $3, status = 'joined', joined_at = NOW() |
| 959 | WHERE workos_organization_id = $1 |
| 960 | AND LOWER(email) = LOWER($2) |
| 961 | AND status = 'invited' |
| 962 | RETURNING *`, |
| 963 | [orgId, email, workosUserId] |
| 964 | ); |
| 965 | return result.rows[0] || null; |
| 966 | } |
| 967 | |
| 968 | /** |
| 969 | * Get a user's expectation for an org (by workos_user_id). |
no outgoing calls
no test coverage detected