From 60fd6953e9c20d27a79bc171e430203e13037224 Mon Sep 17 00:00:00 2001 From: Complexlity Date: Thu, 12 Dec 2024 17:26:40 +0100 Subject: [PATCH] docs: update cron information --- .env.sample | 4 ++++ app/frame/[[...routes]]/route.tsx | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.env.sample b/.env.sample index d3eaeee..52edac4 100644 --- a/.env.sample +++ b/.env.sample @@ -8,6 +8,10 @@ DC_API_KEY= # https://console.upstash.com/qstash QSTASH_CURRENT_SIGNING_KEY= QSTASH_NEXT_SIGNING_KEY= +# Qstash can be removed if using Vercel Cron +# https://vercel.com/docs/cron-jobs/quickstart +# DC cron endpoint: frame/send-notifications +# /frame/[[...routes]]/route.tsx line 44 - 61 can be removed and verified with vercel cron env NEXT_PUBLIC_SITE_URL= NEXT_PUBLIC_GOOGLE_ANALYTICS_ID= diff --git a/app/frame/[[...routes]]/route.tsx b/app/frame/[[...routes]]/route.tsx index bdb9c13..11589ff 100644 --- a/app/frame/[[...routes]]/route.tsx +++ b/app/frame/[[...routes]]/route.tsx @@ -49,6 +49,18 @@ app.hono.post("/send-notifications", async (c) => { } const body = await c.req.text(); const currentDay = getCurrentDateUTC(); + + const isValid = await qstashReceiver + .verify({ + body, + signature, + }) + .catch((e) => false); + + if (!isValid) { + return c.json({ error: "Invalid signature" }, 400); + } + const notificationMessage = ` Day ${currentDay} NFT is now mintable!. @@ -56,18 +68,6 @@ app.hono.post("/send-notifications", async (c) => { N/B: Unsubscribe from getting these notifications through the frame. `; - - const isValid = await qstashReceiver - .verify({ - body, - signature, - }) - .catch((e) => false); - - if (!isValid) { - return c.json({ error: "Invalid signature" }, 400); - } - async function sendUserDCs() { // const userFids = [846887]; const userFids = await kvStore.smembers(UNLOCK_REDIS_KEY);