From ac53b65147716b95e31aa55ebcc1c61309999663 Mon Sep 17 00:00:00 2001 From: Rushil Perera Date: Sun, 22 Sep 2024 15:20:49 -0400 Subject: [PATCH] fix: avoid scheduling next episode notifications on localhost --- src/libs/maybeScheduleNextAiringEpisode.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libs/maybeScheduleNextAiringEpisode.ts b/src/libs/maybeScheduleNextAiringEpisode.ts index a9bbdbc..808ac06 100644 --- a/src/libs/maybeScheduleNextAiringEpisode.ts +++ b/src/libs/maybeScheduleNextAiringEpisode.ts @@ -17,6 +17,15 @@ export async function maybeScheduleNextAiringEpisode( req: HonoRequest, aniListId: number, ) { + const domain = getCurrentDomain(req); + if ( + domain.includes("localhost") || + domain.includes("127.0.0.1") || + domain.includes("192.168.1") + ) { + return; + } + const { nextAiring, status } = await getNextEpisodeTimeUntilAiring(aniListId); if (!nextAiring) { if (status === "NOT_YET_RELEASED") { @@ -31,7 +40,6 @@ export async function maybeScheduleNextAiringEpisode( const { timeUntilAiring, episode: nextEpisode } = nextAiring; const client = new Client({ token: env.QSTASH_TOKEN }); - const domain = getCurrentDomain(req); const { messageId } = await client.publishJSON({ url: `${domain}/internal/new-episode`, body: { aniListId, episodeNumber: nextEpisode },