From cbd8a7a790a288e9d6a758571284f8bd18532463 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Wed, 16 Feb 2022 22:22:46 -0600 Subject: [PATCH] sendMarketCloseEmail: handle unsubscribe --- functions/src/emails.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/functions/src/emails.ts b/functions/src/emails.ts index 72ef20a7..7b930361 100644 --- a/functions/src/emails.ts +++ b/functions/src/emails.ts @@ -95,6 +95,13 @@ export const sendMarketCloseEmail = async ( privateUser: PrivateUser, contract: Contract ) => { + if ( + !privateUser || + privateUser.unsubscribedFromResolutionEmails || + !privateUser.email + ) + return + const { username, name, id: userId } = user const firstName = name.split(' ')[0] @@ -103,7 +110,7 @@ export const sendMarketCloseEmail = async ( const url = `https://manifold.markets/${username}/${slug}` await sendTemplateEmail( - privateUser.email || '', + privateUser.email, 'Your market has closed', 'market-close', {