(params: {
organizationId: string | null
email: string
})
| 102 | } |
| 103 | |
| 104 | async function findPendingInvitationByOrgEmail(params: { |
| 105 | organizationId: string | null |
| 106 | email: string |
| 107 | }) { |
| 108 | const normalized = normalizeEmail(params.email) |
| 109 | |
| 110 | if (params.organizationId) { |
| 111 | const [row] = await db |
| 112 | .select() |
| 113 | .from(invitation) |
| 114 | .where( |
| 115 | and( |
| 116 | eq(invitation.organizationId, params.organizationId), |
| 117 | eq(invitation.email, normalized), |
| 118 | eq(invitation.status, 'pending') |
| 119 | ) |
| 120 | ) |
| 121 | .limit(1) |
| 122 | return row ?? null |
| 123 | } |
| 124 | |
| 125 | const [row] = await db |
| 126 | .select() |
| 127 | .from(invitation) |
| 128 | .where( |
| 129 | and( |
| 130 | sql`${invitation.organizationId} IS NULL`, |
| 131 | eq(invitation.email, normalized), |
| 132 | eq(invitation.status, 'pending') |
| 133 | ) |
| 134 | ) |
| 135 | .limit(1) |
| 136 | return row ?? null |
| 137 | } |
| 138 | |
| 139 | export async function findPendingGrantForWorkspaceEmail(params: { |
| 140 | workspaceId: string |
nothing calls this directly
no test coverage detected