Skip to content

Commit 495630c

Browse files
committed
fix: Fix syntax errors in report notifications API calls
1 parent 0e177e8 commit 495630c

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

src/api/reportNotifications.api.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { httpApi } from './http.api';
2+
3+
// Define NostrEvent interface based on NIP-01 spec
4+
export interface NostrEvent {
5+
id: string;
6+
pubkey: string;
7+
created_at: number;
8+
kind: number;
9+
tags: string[][];
10+
content: string;
11+
sig: string;
12+
}
13+
14+
export interface ReportNotificationParams {
15+
page?: number;
16+
limit?: number;
17+
filter?: 'all' | 'unread';
18+
}
19+
20+
export interface ReportNotification {
21+
id: number;
22+
pubkey: string;
23+
event_id: string;
24+
report_type: string;
25+
report_content: string;
26+
reporter_pubkey: string;
27+
report_count: number;
28+
created_at: string;
29+
updated_at: string;
30+
is_read: boolean;
31+
}
32+
33+
export interface PaginationData {
34+
currentPage: number;
35+
pageSize: number;
36+
totalItems: number;
37+
totalPages: number;
38+
hasNext: boolean;
39+
hasPrevious: boolean;
40+
}
41+
42+
export interface ReportNotificationsResponse {
43+
notifications: ReportNotification[];
44+
pagination: PaginationData;
45+
}
46+
47+
export interface ReportTypeStats {
48+
type: string;
49+
count: number;
50+
}
51+
52+
export interface MostReportedItem {
53+
event_id: string;
54+
pubkey: string;
55+
report_count: number;
56+
report_type: string;
57+
created_at: string;
58+
}
59+
60+
export interface ReportStats {
61+
total_reported: number;
62+
total_reported_today: number;
63+
by_report_type: ReportTypeStats[];
64+
most_reported: MostReportedItem[];
65+
}
66+
67+
// Fetch report notifications with filtering and pagination
68+
export const getReportNotifications = async (
69+
params: ReportNotificationParams = {}
70+
): Promise<ReportNotificationsResponse> => {
71+
const response = await httpApi.get<ReportNotificationsResponse>('/api/reports/notifications', { params });
72+
return response.data;
73+
};
74+
75+
// Mark a specific notification as read
76+
export const markNotificationAsRead = async (id: number): Promise<void> => {
77+
await httpApi.post('/api/reports/notifications/read', { id });
78+
};
79+
80+
// Mark all notifications as read
81+
export const markAllNotificationsAsRead = async (): Promise<void> => {
82+
await httpApi.post('/api/reports/notifications/read-all');
83+
};
84+
85+
// Get report statistics
86+
export const getReportStats = async (): Promise<ReportStats> => {
87+
const response = await httpApi.get<ReportStats>('/api/reports/stats');
88+
return response.data;
89+
};
90+
91+
// Get reported event content
92+
export const getReportedEvent = async (eventId: string): Promise<{event: NostrEvent}> => {
93+
const response = await httpApi.get<{event: NostrEvent}>(`/api/reports/event/${eventId}`);
94+
return response.data;
95+
};
96+
97+
// Delete reported event
98+
export const deleteReportedEvent = async (eventId: string): Promise<{success: boolean; message: string}> => {
99+
const response = await httpApi.delete<{success: boolean; message: string}>(`/api/reports/event/${eventId}`);
100+
return response.data;
101+
};

0 commit comments

Comments
 (0)