Rust discount function (one automatic discount evaluating all offers in priority order, parity with the Odoo engine), React Router admin with Polaris, theme app extension and app proxy pages, webhooks incl. GDPR, managed-pricing limits, and a Docker Compose stack (Postgres + Caddy HTTPS) for a single VPS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import type { ActionFunctionArgs } from "react-router";
|
|
import { authenticate } from "../shopify.server";
|
|
import db from "../db.server";
|
|
|
|
// Mandatory GDPR webhooks. Bundle Offers stores no customer personal data: only order ids, order names and
|
|
// amounts for analytics (no names, emails or addresses). customers/data_request and customers/redact have
|
|
// nothing to return or erase; shop/redact (48 h after uninstall) deletes everything about the shop.
|
|
export const action = async ({ request }: ActionFunctionArgs) => {
|
|
const { shop, topic } = await authenticate.webhook(request);
|
|
switch (topic) {
|
|
case "CUSTOMERS_DATA_REQUEST":
|
|
case "CUSTOMERS_REDACT":
|
|
break;
|
|
case "SHOP_REDACT": {
|
|
const row = await db.shop.findUnique({ where: { domain: shop }, select: { id: true } });
|
|
if (row) {
|
|
await db.orderStat.deleteMany({ where: { shopId: row.id } });
|
|
await db.shop.delete({ where: { id: row.id } }); // cascades to offers, usage and audit log
|
|
}
|
|
await db.session.deleteMany({ where: { shop } });
|
|
break;
|
|
}
|
|
default:
|
|
return new Response("Unhandled topic", { status: 404 });
|
|
}
|
|
return new Response();
|
|
};
|