diff --git a/CHANGELOG.md b/CHANGELOG.md index 47b8fbfe..b2961a35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,16 @@ # @shopify/shopify-app-template-remix -## 2024.12.09 +## 2024.12.19 - [#904](https://github.com/Shopify/shopify-app-template-remix/pull/904) bump `@shopify/app-bridge-react` to latest +- +## 2024.12.18 +- [875](https://github.com/Shopify/shopify-app-template-remix/pull/875) Add Scopes Update Webhook ## 2024.12.05 +- [#910](https://github.com/Shopify/shopify-app-template-remix/pull/910) Install `openssl` in Docker image to fix Prisma (see [#25817](https://github.com/prisma/prisma/issues/25817#issuecomment-2538544254)) +- [#907](https://github.com/Shopify/shopify-app-template-remix/pull/907) Move `@remix-run/fs-routes` to `dependencies` to fix Docker image build - [#899](https://github.com/Shopify/shopify-app-template-remix/pull/899) Disable v3_singleFetch flag - [#898](https://github.com/Shopify/shopify-app-template-remix/pull/898) Enable the `removeRest` future flag so new apps aren't tempted to use the REST Admin API. @@ -14,7 +19,6 @@ - [#891](https://github.com/Shopify/shopify-app-template-remix/pull/891) Enable remix future flags. ## 2024.11.26 - - [888](https://github.com/Shopify/shopify-app-template-remix/pull/888) Update restResources version to 2024-10 ## 2024.11.06 @@ -35,7 +39,7 @@ ## 2024.09.17 -- [842](https://github.com/Shopify/shopify-app-template-remix/pull/842)Move webhook processing to individual routes +- [842](https://github.com/Shopify/shopify-app-template-remix/pull/842) Move webhook processing to individual routes ## 2024.08.19 diff --git a/Dockerfile b/Dockerfile index 98e0c37d..07bc9cf7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM node:18-alpine +RUN apk add --no-cache openssl EXPOSE 3000 diff --git a/app/routes/webhooks.app.scopes_update.tsx b/app/routes/webhooks.app.scopes_update.tsx new file mode 100644 index 00000000..c36bb64c --- /dev/null +++ b/app/routes/webhooks.app.scopes_update.tsx @@ -0,0 +1,21 @@ +import type { ActionFunctionArgs } from "@remix-run/node"; +import { authenticate } from "../shopify.server"; +import db from "../db.server"; + +export const action = async ({ request }: ActionFunctionArgs) => { + const { payload, session, topic, shop } = await authenticate.webhook(request); + console.log(`Received ${topic} webhook for ${shop}`); + + const current = payload.current as string[]; + if (session) { + await db.session.update({ + where: { + id: session.id + }, + data: { + scope: current.toString(), + }, + }); + } + return new Response(); +}; diff --git a/package.json b/package.json index b3210338..4838f7ac 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "dependencies": { "@prisma/client": "^5.11.0", "@remix-run/dev": "^2.7.1", + "@remix-run/fs-routes": "^2.15.0", "@remix-run/node": "^2.7.1", "@remix-run/react": "^2.7.1", "@remix-run/serve": "^2.7.1", @@ -41,7 +42,6 @@ }, "devDependencies": { "@remix-run/eslint-config": "^2.7.1", - "@remix-run/fs-routes": "^2.15.0", "@remix-run/route-config": "^2.15.0", "@shopify/api-codegen-preset": "^1.1.1", "@types/eslint": "^8.40.0", diff --git a/shopify.app.toml b/shopify.app.toml index e1a27650..7215ddf9 100644 --- a/shopify.app.toml +++ b/shopify.app.toml @@ -10,6 +10,11 @@ api_version = "2024-10" uri = "/webhooks/app/uninstalled" topics = ["app/uninstalled"] + # Handled by: /app/routes/webhooks.app.scopes_update.tsx + [[webhooks.subscriptions]] + topics = [ "app/scopes_update" ] + uri = "/webhooks/app/scopes_update" + # Webhooks can have filters # Only receive webhooks for product updates with a product price >= 10.00 # See: https://shopify.dev/docs/apps/build/webhooks/customize/filters