feat: delete message id when title no longer airing
This commit is contained in:
@@ -2,6 +2,7 @@ import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
||||
import { Client } from "@upstash/qstash";
|
||||
import { env } from "hono/adapter";
|
||||
|
||||
import { deleteMessageIdForTitle } from "~/libs/deleteMessageIdForTitle";
|
||||
import { maybeScheduleNextAiringEpisode } from "~/libs/maybeScheduleNextAiringEpisode";
|
||||
import { verifyQstashHeader } from "~/libs/qstash/verifyQstashHeader";
|
||||
import { readEnvVariable } from "~/libs/readEnvVariable";
|
||||
@@ -95,20 +96,10 @@ app.openapi(route, async (c) => {
|
||||
titleId,
|
||||
);
|
||||
} else if (wasDeleted) {
|
||||
const messageId = await getTitleMessage(
|
||||
await deleteMessageIdForTitle(
|
||||
env<Env, typeof c>(c, "workerd"),
|
||||
titleId,
|
||||
);
|
||||
if (messageId) {
|
||||
try {
|
||||
await client.messages.delete(messageId);
|
||||
} catch (error) {
|
||||
if (!error.message.contains("not found")) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
await deleteTitleMessage(env<Env, typeof c>(c, "workerd"), titleId);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(new Error("Error setting watch status", { cause: error }));
|
||||
|
||||
Reference in New Issue
Block a user