mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-01 18:21:52 +02:00
⚡️ Make submitting a participant a bit faster
Send multiple emails in parallel rather than sequentially.
This commit is contained in:
parent
899c890b09
commit
e06c55c131
2 changed files with 23 additions and 19 deletions
|
@ -88,7 +88,7 @@ export const participants = router({
|
||||||
});
|
});
|
||||||
|
|
||||||
const { poll, ...participant } = res;
|
const { poll, ...participant } = res;
|
||||||
|
const emailsToSend: Promise<void>[] = [];
|
||||||
if (email) {
|
if (email) {
|
||||||
const token = await createToken(
|
const token = await createToken(
|
||||||
{ userId: user.id },
|
{ userId: user.id },
|
||||||
|
@ -97,23 +97,29 @@ export const participants = router({
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await sendEmail("NewParticipantConfirmationEmail", {
|
emailsToSend.push(
|
||||||
to: email,
|
sendEmail("NewParticipantConfirmationEmail", {
|
||||||
subject: `Your response for ${poll.title} has been received`,
|
to: email,
|
||||||
props: {
|
subject: `Response submitted: ${poll.title}`,
|
||||||
name,
|
props: {
|
||||||
title: poll.title,
|
name,
|
||||||
editSubmissionUrl: absoluteUrl(
|
title: poll.title,
|
||||||
`/p/${poll.participantUrlId}?token=${token}`,
|
editSubmissionUrl: absoluteUrl(
|
||||||
),
|
`/p/${poll.participantUrlId}?token=${token}`,
|
||||||
},
|
),
|
||||||
});
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await sendNotification(pollId, {
|
emailsToSend.push(
|
||||||
type: "newParticipant",
|
sendNotification(pollId, {
|
||||||
participantName: name,
|
type: "newParticipant",
|
||||||
});
|
participantName: name,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
await Promise.all(emailsToSend);
|
||||||
|
|
||||||
return participant;
|
return participant;
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -76,9 +76,7 @@ test.describe.parallel(() => {
|
||||||
wait: 5000,
|
wait: 5000,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(email.headers.subject).toBe(
|
expect(email.headers.subject).toBe("Response submitted: Lunch Meeting");
|
||||||
"Your response for Lunch Meeting has been received",
|
|
||||||
);
|
|
||||||
|
|
||||||
const $ = load(email.html);
|
const $ = load(email.html);
|
||||||
const href = $("#editSubmissionUrl").attr("href");
|
const href = $("#editSubmissionUrl").attr("href");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue