Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -16,6 +16,8 @@ import { useLoaderData } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { db } from "~/utils/db.server";
|
||||
import { verifyUnsubscribeToken } from "~/utils/email/unsubscribeToken.server";
|
||||
import { verifyMarketingToken } from "~/utils/email/marketingToken.server";
|
||||
import { unsubscribeKontakt } from "~/modules/emailMarketing/services/ConsentService.server";
|
||||
import { createScopedLogger } from "~/utils/logger.server";
|
||||
|
||||
const logger = createScopedLogger("marketing.unsubscribe");
|
||||
@@ -24,7 +26,23 @@ type LoaderData = {
|
||||
status: "ok" | "invalid" | "already_unsubscribed" | "run_not_found";
|
||||
};
|
||||
|
||||
/** Marketing campaign unsubscribe (AK-P14b token, version m1). Tries this first;
|
||||
* falls through to the email-sequence path when the token isn't a marketing one. */
|
||||
async function processMarketingUnsubscribe(token: string): Promise<LoaderData | null> {
|
||||
const payload = verifyMarketingToken(token, { expectedPurpose: "unsub" });
|
||||
if (!payload) return null;
|
||||
const result = await unsubscribeKontakt({ tenantId: payload.tenantId, kontaktId: payload.kontaktId, campaignId: payload.campaignId, reason: "one_click" });
|
||||
logger.info(
|
||||
{ op: "unsubscribe.marketing", kontaktId: payload.kontaktId, tenantId: payload.tenantId, campaignId: payload.campaignId, result },
|
||||
"marketing unsubscribe processed"
|
||||
);
|
||||
return { status: result === "already_unsubscribed" ? "already_unsubscribed" : "ok" };
|
||||
}
|
||||
|
||||
async function processUnsubscribe(token: string): Promise<LoaderData> {
|
||||
const marketing = await processMarketingUnsubscribe(token);
|
||||
if (marketing) return marketing;
|
||||
|
||||
const payload = verifyUnsubscribeToken(token);
|
||||
if (!payload) {
|
||||
logger.warn({ op: "unsubscribe.invalid_token" }, "invalid unsubscribe token");
|
||||
|
||||
Reference in new issue
Block a user