newsletter
parent
88b068bc2c
commit
e5d67bcac3
|
@ -48,8 +48,8 @@ export async function AddNewsletterParticipant(req: Request, res: Response) {
|
|||
newsletterLogger.info("AddNewsletterParticipant", email);
|
||||
|
||||
rabbitmq.sendEmail(email, "confirmNewsletterParticipation", "de", {
|
||||
confirmNewsletterParticipationLink: `${process.env.DASHBOARD_API_URL}/v1/newsletter/confirm/${newsletterId}`,
|
||||
unsubscribeNewsletterParticipationLink: `${process.env.DASHBOARD_API_URL}/v1/newsletter/unsubscribe/${newsletterId}`,
|
||||
confirmNewsletterParticipationLink: `${process.env.NEWSLETTER_WEBSITE_URL}confirm?n=${newsletterId}`,
|
||||
unsubscribeNewsletterParticipationLink: `${process.env.NEWSLETTER_WEBSITE_URL}unsubscribe?n=${newsletterId}`,
|
||||
privacyPolicyLink:
|
||||
process.env.NEWSLETTER_PRIVACY_POLICY_URLS?.split(",")[0],
|
||||
});
|
||||
|
@ -93,6 +93,7 @@ export async function ConfirmNewsletterParticipation(
|
|||
return res.status(400).send({ err: "invalid request" });
|
||||
}
|
||||
|
||||
if (newsletterParticipant.state !== NEWSLETTER_STATE.CONFIRMED) {
|
||||
newsletterParticipant.state = NEWSLETTER_STATE.CONFIRMED;
|
||||
await newsletterParticipant.save();
|
||||
|
||||
|
@ -101,14 +102,21 @@ export async function ConfirmNewsletterParticipation(
|
|||
"confirmedNewsletterParticipation",
|
||||
"de",
|
||||
{
|
||||
unsubscribeNewsletterParticipationLink: `${process.env.DASHBOARD_API_URL}/v1/newsletter/unsubscribe/${newsletterId}`,
|
||||
unsubscribeNewsletterParticipationLink: `${process.env.NEWSLETTER_WEBSITE_URL}unsubscribe?n=${newsletterId}`,
|
||||
privacyPolicyLink: process.env.NEWSLETTER_PRIVACY_POLICY_URLS?.split(
|
||||
","
|
||||
).find((url) => url.includes(newsletterParticipant.type)),
|
||||
}
|
||||
);
|
||||
|
||||
newsletterLogger.info("ConfirmNewsletterParticipation", newsletterId);
|
||||
newsletterLogger.info(
|
||||
`ConfirmNewsletterParticipation newsletterId: ${newsletterId} email: ${newsletterParticipant.email} confirmed`
|
||||
);
|
||||
} else {
|
||||
newsletterLogger.warn(
|
||||
`ConfirmNewsletterParticipation: newsletter id: ${newsletterId} email: ${newsletterParticipant.email} already confirmed`
|
||||
);
|
||||
}
|
||||
|
||||
return res.status(200).send({ status: "success" });
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue