mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
feat: add rate limits to import/export
This commit is contained in:
parent
45941e47d6
commit
fc4f106afb
3 changed files with 32 additions and 2 deletions
|
@ -5,6 +5,8 @@ import { clientError, ok } from "../responses";
|
|||
import { GuildCases } from "../../data/GuildCases";
|
||||
import { z } from "zod";
|
||||
import { Case } from "../../data/entities/Case";
|
||||
import { rateLimit } from "../rateLimits";
|
||||
import { MINUTES } from "../../utils";
|
||||
|
||||
const caseHandlingModeSchema = z.union([
|
||||
z.literal("replace"),
|
||||
|
@ -62,6 +64,11 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) {
|
|||
importExportRouter.post(
|
||||
"/:guildId/import",
|
||||
requireGuildPermission(ApiPermissions.ManageAccess),
|
||||
rateLimit(
|
||||
(req) => `import-${req.params.guildId}`,
|
||||
5 * MINUTES,
|
||||
"A single server can only import data once every 5 minutes",
|
||||
),
|
||||
async (req: Request, res: Response) => {
|
||||
let data: TImportExportData;
|
||||
try {
|
||||
|
@ -119,6 +126,11 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) {
|
|||
importExportRouter.post(
|
||||
"/:guildId/export",
|
||||
requireGuildPermission(ApiPermissions.ManageAccess),
|
||||
rateLimit(
|
||||
(req) => `export-${req.params.guildId}`,
|
||||
5 * MINUTES,
|
||||
"A single server can only export data once every 5 minutes",
|
||||
),
|
||||
async (req: Request, res: Response) => {
|
||||
const guildCases = GuildCases.getGuildInstance(req.params.guildId);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue