only send TX-Receive-Email after disbursement if recipient.email exists

This commit is contained in:
clauspeterhuebner 2026-01-07 16:41:52 +01:00
parent 6b558c9256
commit 3f648bcadc

View File

@ -674,6 +674,11 @@ export class TransactionLinkResolver {
methodLogger.error(errmsg)
throw new LogError(errmsg)
}
if(recipientUser.emailContact?.email !== null){
if (methodLogger.isDebugEnabled()) {
methodLogger.debug('Sending Transaction Received Email to recipient:', recipientUser.firstName, recipientUser.lastName)
}
try {
await sendTransactionReceivedEmail({
firstName: recipientFirstName,
lastName: recipientUser.lastName,
@ -685,7 +690,16 @@ export class TransactionLinkResolver {
senderEmail: senderUser.emailContact.email,
transactionAmount: new Decimal(amount),
})
} catch (e) {
const errmsg = `Send Transaction Received Email to recipient failed with error=${e}`
methodLogger.error(errmsg)
throw new Error(errmsg)
}
} else {
if (methodLogger.isDebugEnabled()) {
methodLogger.debug('Recipient as foreign user has no email contact, not sending Transaction Received Email to recipient:', recipientUser.firstName, recipientUser.lastName)
}
}
} catch (e) {
const errmsg = `Disburse JWT was not sent successfully with error=${e}`
methodLogger.error(errmsg)