Some fixes

This commit is contained in:
2025-06-11 23:03:40 +09:00
parent 71d3f1912d
commit 6e2700fe3d
8 changed files with 423 additions and 193 deletions

View File

@ -8,17 +8,17 @@ import { batchScheduler } from "./services/batch-scheduler.js";
import { config } from "./services/config.js";
import { closeBrowser } from "./services/content-extractor.js";
import {
deleteCategoryFromBoth,
deleteEpisode,
deleteEpisodeCategory,
deleteFeed,
deleteFeedCategory,
fetchAllEpisodes,
fetchEpisodesWithArticles,
getAllCategories,
getAllFeedsIncludingInactive,
getAllUsedCategories,
getCategoryCounts,
deleteCategoryFromBoth,
deleteFeedCategory,
deleteEpisodeCategory,
getFeedByUrl,
getFeedRequests,
getFeedsByCategory,
@ -375,14 +375,19 @@ app.get("/api/admin/categories/:category/counts", async (c) => {
app.delete("/api/admin/categories/:category", async (c) => {
try {
const category = decodeURIComponent(c.req.param("category"));
const { target } = await c.req.json<{ target: "feeds" | "episodes" | "both" }>();
const { target } = await c.req.json<{
target: "feeds" | "episodes" | "both";
}>();
if (!category || category.trim() === "") {
return c.json({ error: "Category name is required" }, 400);
}
if (!target || !["feeds", "episodes", "both"].includes(target)) {
return c.json({ error: "Valid target (feeds, episodes, or both) is required" }, 400);
return c.json(
{ error: "Valid target (feeds, episodes, or both) is required" },
400,
);
}
console.log(`🗑️ Admin deleting category "${category}" from ${target}`);
@ -396,7 +401,7 @@ app.delete("/api/admin/categories/:category", async (c) => {
category,
feedChanges: result.feedChanges,
episodeChanges: result.episodeChanges,
totalChanges: result.feedChanges + result.episodeChanges
totalChanges: result.feedChanges + result.episodeChanges,
});
} else if (target === "feeds") {
const changes = await deleteFeedCategory(category);
@ -406,7 +411,7 @@ app.delete("/api/admin/categories/:category", async (c) => {
category,
feedChanges: changes,
episodeChanges: 0,
totalChanges: changes
totalChanges: changes,
});
} else if (target === "episodes") {
const changes = await deleteEpisodeCategory(category);
@ -416,7 +421,7 @@ app.delete("/api/admin/categories/:category", async (c) => {
category,
feedChanges: 0,
episodeChanges: changes,
totalChanges: changes
totalChanges: changes,
});
}
} catch (error) {