Skip to content

Commit 748d8ee

Browse files
committed
new build
1 parent d616c7f commit 748d8ee

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

src/api/routes/stripe.ts

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -275,34 +275,43 @@ const stripeRoutes: FastifyPluginAsync = async (fastify, _options) => {
275275
request.log.info(
276276
`Registered payment of ${withCurrency} by ${name} (${email}) for payment link ${paymentLinkId} invoice ID ${unmarshalledEntry.invoiceId}).`,
277277
);
278-
const sqsPayload: SQSPayload<AvailableSQSFunctions.EmailNotifications> =
279-
{
280-
function: AvailableSQSFunctions.EmailNotifications,
281-
metadata: {
282-
initiator: eventId,
283-
reqId: request.id,
284-
},
285-
payload: {
286-
to: [unmarshalledEntry.invoiceId],
287-
subject: `Payment Recieved for Invoice ${unmarshalledEntry.invoiceId}`,
288-
content: `Received payment of ${withCurrency} by ${name} (${email}) for invoice ID ${unmarshalledEntry.invoiceId}. Please contact [email protected] with any questions.`,
289-
},
290-
};
291-
if (!fastify.sqsClient) {
292-
fastify.sqsClient = new SQSClient({
293-
region: genericConfig.AwsRegion,
278+
if (unmarshalledEntry.userId.includes("@")) {
279+
request.log.info(
280+
`Sending email to ${unmarshalledEntry.userId}...`,
281+
);
282+
const sqsPayload: SQSPayload<AvailableSQSFunctions.EmailNotifications> =
283+
{
284+
function: AvailableSQSFunctions.EmailNotifications,
285+
metadata: {
286+
initiator: eventId,
287+
reqId: request.id,
288+
},
289+
payload: {
290+
to: [unmarshalledEntry.userId],
291+
subject: `Payment Recieved for Invoice ${unmarshalledEntry.invoiceId}`,
292+
content: `Received payment of ${withCurrency} by ${name} (${email}) for invoice ID ${unmarshalledEntry.invoiceId}. Please contact [email protected] with any questions.`,
293+
},
294+
};
295+
if (!fastify.sqsClient) {
296+
fastify.sqsClient = new SQSClient({
297+
region: genericConfig.AwsRegion,
298+
});
299+
}
300+
const result = await fastify.sqsClient.send(
301+
new SendMessageCommand({
302+
QueueUrl: fastify.environmentConfig.SqsQueueUrl,
303+
MessageBody: JSON.stringify(sqsPayload),
304+
}),
305+
);
306+
return reply.status(200).send({
307+
handled: true,
308+
requestId: request.id,
309+
queueId: result.MessageId,
294310
});
295311
}
296-
const result = await fastify.sqsClient.send(
297-
new SendMessageCommand({
298-
QueueUrl: fastify.environmentConfig.SqsQueueUrl,
299-
MessageBody: JSON.stringify(sqsPayload),
300-
}),
301-
);
302312
return reply.status(200).send({
303313
handled: true,
304314
requestId: request.id,
305-
queueId: result.MessageId,
306315
});
307316
}
308317
return reply

0 commit comments

Comments
 (0)