Icon rebuilt as a full-bleed 1200x1200 square (Shopify rounds corners itself). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
966 B
TypeScript
17 lines
966 B
TypeScript
import type { ActionFunctionArgs } from "react-router";
|
|
import { authenticate } from "../shopify.server";
|
|
import db from "../db.server";
|
|
|
|
// The access token is already revoked here, so the app can't call the Admin API. Shopify removes the app's
|
|
// functions with the app, so the automatic discount stops applying, and it deletes app-owned ($app and
|
|
// app-data) metafields. We mark the shop and keep its data for 48 h, until shop/redact deletes it.
|
|
// The in-app "Remove all Offerlyst data" action (Settings) deletes the discount explicitly.
|
|
export const action = async ({ request }: ActionFunctionArgs) => {
|
|
const { shop, session, topic } = await authenticate.webhook(request);
|
|
console.log(`Received ${topic} webhook for ${shop}`);
|
|
|
|
await db.shop.updateMany({ where: { domain: shop }, data: { uninstalledAt: new Date(), discountNodeId: null, nextSyncAt: null } });
|
|
if (session) await db.session.deleteMany({ where: { shop } });
|
|
return new Response();
|
|
};
|