Skip to content

Commit

Permalink
fix(email): preserve emails that cannot be sent
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiDood committed Aug 10, 2024
1 parent 855d7ad commit ceb1497
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions email/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ async function listenForDraftNotifications(emailer: Emailer, signal: AbortSignal

assert(meta !== null, 'notify:draft => unexpected notification type');
const email = await emailer.send(await meta.emails, meta.subject, meta.message);
if (email === null) return null;

assert(await db.dropDraftNotification(notif.notif_id), 'cannot drop non-existent notification');
return email;
});
Expand All @@ -85,6 +87,7 @@ async function listenForUserNotifications(emailer: Emailer, signal: AbortSignal)
`[DRAP] Assigned to ${notif.lab_id.toUpperCase()}`,
`Hello, ${notif.given_name} ${notif.family_name}! Kindly note that you have been assigned to the ${notif.lab_name}.`,
);
if (email === null) return null;

assert(await db.dropUserNotification(notif.notif_id), 'cannot drop non-existent notification');
return email;
Expand Down

0 comments on commit ceb1497

Please sign in to comment.