Update dashboard and Docker compose
Some checks failed
CI/CD Pipeline / Security Scanning (push) Has been cancelled
CI/CD Pipeline / Tests (3.11) (push) Has been cancelled
CI/CD Pipeline / Tests (3.12) (push) Has been cancelled
CI/CD Pipeline / Build Docker Image (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (push) Has been cancelled
Some checks failed
CI/CD Pipeline / Security Scanning (push) Has been cancelled
CI/CD Pipeline / Tests (3.11) (push) Has been cancelled
CI/CD Pipeline / Tests (3.12) (push) Has been cancelled
CI/CD Pipeline / Build Docker Image (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (push) Has been cancelled
This commit is contained in:
@@ -13,16 +13,16 @@ import type {
|
||||
PaginatedLogs,
|
||||
UserNote,
|
||||
UserProfile,
|
||||
} from '../types/api';
|
||||
} from "../types/api";
|
||||
|
||||
const BASE_URL = '';
|
||||
const BASE_URL = "";
|
||||
|
||||
async function fetchJson<T>(url: string, options?: RequestInit): Promise<T> {
|
||||
const response = await fetch(BASE_URL + url, {
|
||||
...options,
|
||||
credentials: 'include',
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
@@ -37,38 +37,66 @@ async function fetchJson<T>(url: string, options?: RequestInit): Promise<T> {
|
||||
|
||||
// Auth API
|
||||
export const authApi = {
|
||||
getMe: () => fetchJson<Me>('/api/me'),
|
||||
getMe: () => fetchJson<Me>("/api/me"),
|
||||
};
|
||||
|
||||
// Guilds API
|
||||
export const guildsApi = {
|
||||
list: () => fetchJson<Guild[]>('/api/guilds'),
|
||||
list: () => fetchJson<Guild[]>("/api/guilds"),
|
||||
getSettings: (guildId: number) =>
|
||||
fetchJson<GuildSettings>(`/api/guilds/${guildId}/settings`),
|
||||
updateSettings: (guildId: number, settings: GuildSettings) =>
|
||||
fetchJson<GuildSettings>(`/api/guilds/${guildId}/settings`, {
|
||||
method: 'PUT',
|
||||
method: "PUT",
|
||||
body: JSON.stringify(settings),
|
||||
}),
|
||||
getAutomodConfig: (guildId: number) =>
|
||||
fetchJson<AutomodRuleConfig>(`/api/guilds/${guildId}/automod`),
|
||||
updateAutomodConfig: (guildId: number, config: AutomodRuleConfig) =>
|
||||
fetchJson<AutomodRuleConfig>(`/api/guilds/${guildId}/automod`, {
|
||||
method: 'PUT',
|
||||
method: "PUT",
|
||||
body: JSON.stringify(config),
|
||||
}),
|
||||
exportConfig: (guildId: number) =>
|
||||
fetch(`${BASE_URL}/api/guilds/${guildId}/export`, {
|
||||
credentials: 'include',
|
||||
credentials: "include",
|
||||
}).then((res) => res.blob()),
|
||||
};
|
||||
|
||||
// Moderation API
|
||||
type ModerationLogQuery = {
|
||||
guildId?: number;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
action?: string;
|
||||
messageOnly?: boolean;
|
||||
search?: string;
|
||||
};
|
||||
|
||||
export const moderationApi = {
|
||||
getLogs: (guildId?: number, limit = 50, offset = 0) => {
|
||||
const params = new URLSearchParams({ limit: String(limit), offset: String(offset) });
|
||||
getLogs: ({
|
||||
guildId,
|
||||
limit = 50,
|
||||
offset = 0,
|
||||
action,
|
||||
messageOnly,
|
||||
search,
|
||||
}: ModerationLogQuery = {}) => {
|
||||
const params = new URLSearchParams({
|
||||
limit: String(limit),
|
||||
offset: String(offset),
|
||||
});
|
||||
if (guildId) {
|
||||
params.set('guild_id', String(guildId));
|
||||
params.set("guild_id", String(guildId));
|
||||
}
|
||||
if (action) {
|
||||
params.set("action", action);
|
||||
}
|
||||
if (messageOnly) {
|
||||
params.set("message_only", "true");
|
||||
}
|
||||
if (search) {
|
||||
params.set("search", search);
|
||||
}
|
||||
return fetchJson<PaginatedLogs>(`/api/moderation/logs?${params}`);
|
||||
},
|
||||
@@ -79,28 +107,38 @@ export const analyticsApi = {
|
||||
getSummary: (guildId?: number, days = 7) => {
|
||||
const params = new URLSearchParams({ days: String(days) });
|
||||
if (guildId) {
|
||||
params.set('guild_id', String(guildId));
|
||||
params.set("guild_id", String(guildId));
|
||||
}
|
||||
return fetchJson<AnalyticsSummary>(`/api/analytics/summary?${params}`);
|
||||
},
|
||||
getModerationStats: (guildId?: number, days = 30) => {
|
||||
const params = new URLSearchParams({ days: String(days) });
|
||||
if (guildId) {
|
||||
params.set('guild_id', String(guildId));
|
||||
params.set("guild_id", String(guildId));
|
||||
}
|
||||
return fetchJson<ModerationStats>(`/api/analytics/moderation-stats?${params}`);
|
||||
return fetchJson<ModerationStats>(
|
||||
`/api/analytics/moderation-stats?${params}`,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
// Users API
|
||||
export const usersApi = {
|
||||
search: (guildId: number, username?: string, minStrikes?: number, limit = 50) => {
|
||||
const params = new URLSearchParams({ guild_id: String(guildId), limit: String(limit) });
|
||||
search: (
|
||||
guildId?: number,
|
||||
username?: string,
|
||||
minStrikes?: number,
|
||||
limit = 50,
|
||||
) => {
|
||||
const params = new URLSearchParams({ limit: String(limit) });
|
||||
if (guildId) {
|
||||
params.set("guild_id", String(guildId));
|
||||
}
|
||||
if (username) {
|
||||
params.set('username', username);
|
||||
params.set("username", username);
|
||||
}
|
||||
if (minStrikes !== undefined) {
|
||||
params.set('min_strikes', String(minStrikes));
|
||||
params.set("min_strikes", String(minStrikes));
|
||||
}
|
||||
return fetchJson<UserProfile[]>(`/api/users/search?${params}`);
|
||||
},
|
||||
@@ -110,11 +148,14 @@ export const usersApi = {
|
||||
fetchJson<UserNote[]>(`/api/users/${userId}/notes?guild_id=${guildId}`),
|
||||
createNote: (userId: number, guildId: number, note: CreateUserNote) =>
|
||||
fetchJson<UserNote>(`/api/users/${userId}/notes?guild_id=${guildId}`, {
|
||||
method: 'POST',
|
||||
method: "POST",
|
||||
body: JSON.stringify(note),
|
||||
}),
|
||||
deleteNote: (userId: number, noteId: number, guildId: number) =>
|
||||
fetchJson<void>(`/api/users/${userId}/notes/${noteId}?guild_id=${guildId}`, {
|
||||
method: 'DELETE',
|
||||
}),
|
||||
fetchJson<void>(
|
||||
`/api/users/${userId}/notes/${noteId}?guild_id=${guildId}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
},
|
||||
),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user