* Check if we've already sent a specific email type to a user
(data: {
email_type: string;
workos_user_id: string;
})
| 119 | * Check if we've already sent a specific email type to a user |
| 120 | */ |
| 121 | async hasEmailBeenSent(data: { |
| 122 | email_type: string; |
| 123 | workos_user_id: string; |
| 124 | }): Promise<boolean> { |
| 125 | const result = await query<{ exists: boolean }>( |
| 126 | `SELECT EXISTS( |
| 127 | SELECT 1 FROM email_events |
| 128 | WHERE email_type = $1 |
| 129 | AND workos_user_id = $2 |
| 130 | AND sent_at IS NOT NULL |
| 131 | ) as exists`, |
| 132 | [data.email_type, data.workos_user_id] |
| 133 | ); |
| 134 | return result.rows[0]?.exists || false; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Record a click event |
no outgoing calls
no test coverage detected