- Persist structured verdict (flags/severity/confidence/evidence) on moderation_actions so the public web can show WHY a message was moderated. - Add a persistent Qdrant archive collection (gmw_message_archive); embed every captured message at capture time (fire-and-forget, best-effort). - Public semantic search over the archive (backend oRPC + FE toggle on the messages view). Both features are read-only/public and fully automatic. Migration: 0015_add_moderation_explainability.sql
52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const messageQuerySchema = z.object({
|
|
channelId: z.string().optional(),
|
|
guildId: z.string().optional(),
|
|
userId: z.string().optional(),
|
|
status: z.enum(["pending", "clean", "warn", "flagged", "error"]).optional(),
|
|
limit: z.coerce.number().int().positive().default(50),
|
|
offset: z.coerce.number().int().nonnegative().default(0),
|
|
cursor: z.string().optional(),
|
|
// Filter attachments to a single message (used by the message detail view)
|
|
messageId: z.string().optional(),
|
|
});
|
|
|
|
export const messageCreateSchema = z.object({
|
|
guildId: z.string(),
|
|
channelId: z.string(),
|
|
threadId: z.string().optional(),
|
|
userId: z.string(),
|
|
username: z.string(),
|
|
avatarUrl: z.string().optional(),
|
|
content: z.string(),
|
|
type: z.enum(["text", "edited", "deleted"]).default("text"),
|
|
isReply: z.boolean().optional(),
|
|
isForward: z.boolean().optional(),
|
|
isCrosspost: z.boolean().optional(),
|
|
referenceMessageId: z.string().optional(),
|
|
referenceChannelId: z.string().optional(),
|
|
referenceGuildId: z.string().optional(),
|
|
});
|
|
|
|
export const messageUpdateSchema = z.object({
|
|
editedContent: z.string().optional(),
|
|
aiStatus: z.enum(["pending", "clean", "warn", "flagged", "error"]).optional(),
|
|
aiAnalysis: z.string().optional(),
|
|
aiCategories: z.string().optional(),
|
|
aiSeverity: z.enum(["none", "low", "medium", "high", "critical"]).optional(),
|
|
aiConfidence: z.number().optional(),
|
|
});
|
|
|
|
export type MessageQuery = z.infer<typeof messageQuerySchema>;
|
|
export type MessageCreate = z.infer<typeof messageCreateSchema>;
|
|
export type MessageUpdate = z.infer<typeof messageUpdateSchema>;
|
|
|
|
export const semanticSearchSchema = z.object({
|
|
query: z.string().min(1).max(500),
|
|
limit: z.coerce.number().int().positive().max(50).default(10),
|
|
guildId: z.string().optional(),
|
|
});
|
|
|
|
export type SemanticSearchQuery = z.infer<typeof semanticSearchSchema>;
|