fix: avoid scheduling next episode notifications on localhost
This commit is contained in:
@@ -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 },
|
||||||
|
|||||||
Reference in New Issue
Block a user