Repository navigation
Expand file tree
/
Copy pathreport.ts
More file actions
79 lines (67 loc) · 2.31 KB
/
Copy pathreport.ts
File metadata and controls
79 lines (67 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import z from "zod";
// Report reasons (matching database enum)
export const ReportReasonSchema = z.enum([
"SPAM",
"HARASSMENT",
"HATE_SPEECH",
"MISINFORMATION",
"COPYRIGHT",
"NSFW",
"OFF_TOPIC",
"OTHER",
]);
export type ReportReason = z.TypeOf<typeof ReportReasonSchema>;
// Legacy report schema (for backwards compatibility).
// Note: post flags now route through report.create (the unified content_report
// flow), so "post" is intentionally NOT part of this union — report.send only
// handles comment + feed-article reports.
export const ReportSchema = z.discriminatedUnion("type", [
z.strictObject({
type: z.literal("comment"),
id: z.number().int(),
body: z.string(),
}),
z.strictObject({
type: z.literal("article"),
id: z.number().int(),
body: z.string(),
}),
]);
export type ReportInput = z.TypeOf<typeof ReportSchema>;
// New unified report schema
export const CreateReportSchema = z.object({
contentId: z.string().optional(), // For legacy content reports
discussionId: z.number().optional(), // For discussion reports
postId: z.string().optional(), // For post reports (posts.id is a uuid)
reason: ReportReasonSchema,
details: z.string().max(1000).optional(), // Optional additional details
});
export type CreateReportInput = z.TypeOf<typeof CreateReportSchema>;
// Admin: Get reports schema
export const GetReportsSchema = z.object({
status: z.enum(["PENDING", "REVIEWED", "DISMISSED", "ACTIONED"]).optional(),
reason: ReportReasonSchema.optional(),
limit: z.number().min(1).max(100).default(20),
cursor: z
.object({
id: z.number(),
createdAt: z.string().optional(),
})
.nullish(),
});
export type GetReportsInput = z.TypeOf<typeof GetReportsSchema>;
// Admin: Review report schema
export const ReviewReportSchema = z.object({
reportId: z.number(),
status: z.enum(["REVIEWED", "DISMISSED", "ACTIONED"]),
actionTaken: z.string().max(500).optional(),
});
export type ReviewReportInput = z.TypeOf<typeof ReviewReportSchema>;
// Admin: Dismiss a system (auto-flagged) report. `reportId` is a `reports` id,
// a separate sequence from the ContentReport ids ReviewReportSchema takes.
export const DismissSystemReportSchema = z.object({
reportId: z.number(),
});
export type DismissSystemReportInput = z.TypeOf<
typeof DismissSystemReportSchema
>;