Skip to content

Commit

Permalink
Add scopes update webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
allenchazhoor committed Oct 28, 2024
1 parent e4bf2ab commit c95b795
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/routes/webhooks.app.scopes_update.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 } = await authenticate.webhook(request);
const current = payload.current as string[];
if (session) {
await db.session.update({
where: {
id: session.id
},
data: {
scope: current.toString(),
},
});
}
return new Response();
};
5 changes: 5 additions & 0 deletions shopify.app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ api_version = "2024-07"
uri = "/webhooks/app/uninstalled"
topics = ["app/uninstalled"]

# Handled by: /app/routes/webhooks.app.scopes.update.tsx
[[webhooks.subscriptions]]
topics = [ "app/uninstalled" ]
uri = "/webhooks/app/uninstalled"

# 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
Expand Down

0 comments on commit c95b795

Please sign in to comment.