import type { ActionFunctionArgs } from "react-router"; import { authenticate } from "../shopify.server"; import db from "../db.server"; // Mandatory GDPR webhooks. Offerlyst 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(); };