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