Manual per-message and batch reanalyze buttons/endpoints let anyone re-queue arbitrary messages for LLM analysis, burning AI credits on spam. Removed: - FE: Reanalyze buttons in message list, search panel, and messages page - FE: useReanalyze/useReanalyzeBatch hooks + messagesApi methods - BE: POST /api/messages/:id/reanalyze and /reanalyze-batch endpoints - BE: markForReanalysis/reanalyzeErrorBatch service+repository methods Recovery of failed messages is fully automatic: the discord-gateway startPendingAIAnalysisWorker retries 'pending' (batch path) and 'error/analysis_incomplete' (individual path) messages on AI_ANALYSIS_RECOVERY_INTERVAL_MS.
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import type { Request, Response, Router } from "express";
|
|
import express from "express";
|
|
import { createChildLogger } from "@/shared/logger/index";
|
|
import { asyncHandler } from "../../shared/middlewares/index.js";
|
|
import {
|
|
handleGetAttachmentsByChannel,
|
|
handleGetImageMessages,
|
|
handleGetMessageById,
|
|
handleGetMessagesByChannel,
|
|
handleListMessages,
|
|
} from "./messages.controller.js";
|
|
import { messagesService } from "./messages.service.js";
|
|
|
|
const logger = createChildLogger("messages.routes");
|
|
|
|
export function createMessagesRouter(): Router {
|
|
const router = express.Router();
|
|
|
|
// GET /api/messages/images - Get messages with image attachments
|
|
// MUST be registered BEFORE /messages/:channelId so "images" is not
|
|
// captured as a channelId param.
|
|
router.get("/messages/images", handleGetImageMessages);
|
|
|
|
// GET /api/messages - List messages
|
|
router.get("/messages", handleListMessages);
|
|
|
|
// GET /api/messages/:channelId - Get messages by channel
|
|
router.get("/messages/:channelId", handleGetMessagesByChannel);
|
|
|
|
// GET /api/messages/:channelId/attachments - Get attachments by channel
|
|
router.get("/messages/:channelId/attachments", handleGetAttachmentsByChannel);
|
|
|
|
// GET /api/messages/detail/:id - Get single message by ID
|
|
// (uses /detail/ prefix to avoid collision with :channelId route above)
|
|
router.get("/messages/detail/:id", handleGetMessageById);
|
|
|
|
// GET /api/review - Get flagged/warned messages for review
|
|
router.get(
|
|
"/review",
|
|
asyncHandler(async (req: Request, res: Response) => {
|
|
const limit = Number(req.query.limit) || 20;
|
|
const channelId = (req.query.channelId as string) || undefined;
|
|
|
|
const rows = await messagesService.getReviewMessages(channelId, limit);
|
|
logger.debug({ limit, channelId }, "Review query executed");
|
|
res.json({ results: rows, limit, cursor: null });
|
|
}),
|
|
);
|
|
|
|
return router;
|
|
}
|