Some fixes
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user