fix: avoid scheduling next episode notifications on localhost

This commit is contained in:
2024-09-22 15:20:49 -04:00
parent ecbddbc574
commit ac53b65147

View File

@@ -17,6 +17,15 @@ export async function maybeScheduleNextAiringEpisode(
req: HonoRequest, req: HonoRequest,
aniListId: number, 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); const { nextAiring, status } = await getNextEpisodeTimeUntilAiring(aniListId);
if (!nextAiring) { if (!nextAiring) {
if (status === "NOT_YET_RELEASED") { if (status === "NOT_YET_RELEASED") {
@@ -31,7 +40,6 @@ export async function maybeScheduleNextAiringEpisode(
const { timeUntilAiring, episode: nextEpisode } = nextAiring; const { timeUntilAiring, episode: nextEpisode } = nextAiring;
const client = new Client({ token: env.QSTASH_TOKEN }); const client = new Client({ token: env.QSTASH_TOKEN });
const domain = getCurrentDomain(req);
const { messageId } = await client.publishJSON({ const { messageId } = await client.publishJSON({
url: `${domain}/internal/new-episode`, url: `${domain}/internal/new-episode`,
body: { aniListId, episodeNumber: nextEpisode }, body: { aniListId, episodeNumber: nextEpisode },