16986 unsubscribe link

This commit is contained in:
2025-06-02 17:41:39 +01:00
parent 8b244ffb94
commit 6c7eca581b
6 changed files with 351 additions and 9 deletions
+9 -7
View File
@@ -64,7 +64,7 @@ const buildNotifyPayloads = (watchlistByEmail) => {
const link =
process.env.NEXTAUTH_URL + doc.pinswg_hashlink ||
"[No Link]";
return ` - ${ref}: ${name} (${date})\n Link: ${link}`;
return ` - ${name} (${date})\n Link: ${link}`;
})
.join("\n");
@@ -105,7 +105,7 @@ const buildNotifyPayloads = (watchlistByEmail) => {
.map(([email, entries]) => {
const contactName =
entries[0].firstname + " " + entries[0].lastname;
const contactId = entries[0].contactId;
const contactId = entries[0].contactid;
const filteredEntries = entries.filter(
(entry) =>
@@ -140,9 +140,11 @@ const buildNotifyPayloads = (watchlistByEmail) => {
)}\n`
: "";
const caseUnsubscribelink = `Unsubscribe to updates on this case https://${process.env.NEXTAUTH_URL}/unsubscribe/${entry.pinswg_watchlistid}`;
const caseUnsubscribelink = `Unsubscribe to updates on this case ${process.env.NEXTAUTH_URL}/unsubscribe/${entry.pinswg_watchlistid}`;
return `Case: ${caseRef}\n${[
return `Case: ${caseRef}\nLink to case:${
process.env.NEXTAUTH_URL
}/case/${caseRef}\n\n${[
docSection,
sipSection,
repsSection,
@@ -153,7 +155,7 @@ const buildNotifyPayloads = (watchlistByEmail) => {
})
.join("\n\n"),
unsubscribeLink: `Unsubscribe by selecting this link if you no longer want to receive any updates ${
process.env.NEXTAUTH_URL + "unsubscribeall/" + "contactId"
process.env.NEXTAUTH_URL + "/unsubscribeall/" + contactId
}`,
};
@@ -163,7 +165,7 @@ const buildNotifyPayloads = (watchlistByEmail) => {
personalisation,
reference,
oneClickUnsubscribeURL:
process.env.NEXTAUTH_URL + "unsubscribe/" + "eee",
process.env.NEXTAUTH_URL + "/unsubscribeall/" + contactId,
};
})
.filter(Boolean); // Remove any nulls from filtered-out users
@@ -280,7 +282,7 @@ export default async function CombinedApiProxy(req, res) {
for (const payload of payloads) {
if (!payload) continue; // skip null entries
console.log(payload);
//console.log(payload);
const result = {
email: payload.email_address,
reference: payload.reference,