fix: ratelimit - updates (#10347)
parent
4f488be654
commit
8cdddfa1d0
|
@ -7,7 +7,7 @@ import logger from "./logger";
|
|||
const log = logger.getChildLogger({ prefix: ["RateLimit"] });
|
||||
|
||||
export type RateLimitHelper = {
|
||||
rateLimitingType?: "core" | "forcedSlowMode";
|
||||
rateLimitingType?: "core" | "forcedSlowMode" | "common";
|
||||
identifier: string;
|
||||
};
|
||||
|
||||
|
@ -57,6 +57,12 @@ export function rateLimiter() {
|
|||
prefix: "ratelimit",
|
||||
limiter: Ratelimit.fixedWindow(10, "60s"),
|
||||
}),
|
||||
common: new Ratelimit({
|
||||
redis,
|
||||
analytics: true,
|
||||
prefix: "ratelimit",
|
||||
limiter: Ratelimit.fixedWindow(200, "60s"),
|
||||
}),
|
||||
forcedSlowMode: new Ratelimit({
|
||||
redis,
|
||||
analytics: true,
|
||||
|
|
|
@ -2,6 +2,7 @@ import { type PrismaClient, Prisma } from "@prisma/client";
|
|||
import { orderBy } from "lodash";
|
||||
|
||||
import { hasFilter } from "@calcom/features/filters/lib/hasFilter";
|
||||
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
||||
import { CAL_URL } from "@calcom/lib/constants";
|
||||
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
||||
import { getBookerUrl } from "@calcom/lib/server/getBookerUrl";
|
||||
|
@ -78,6 +79,11 @@ export const compareMembership = (mship1: MembershipRole, mship2: MembershipRole
|
|||
export const getByViewerHandler = async ({ ctx, input }: GetByViewerOptions) => {
|
||||
const { prisma } = ctx;
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
identifier: `eventTypes:getByViewer:${ctx.user.id}`,
|
||||
rateLimitingType: "common",
|
||||
});
|
||||
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
id: ctx.user.id,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
|
||||
import type { TrpcSessionUser } from "../../../trpc";
|
||||
|
@ -9,6 +10,10 @@ type ListOptions = {
|
|||
};
|
||||
|
||||
export const listHandler = async ({ ctx }: ListOptions) => {
|
||||
await checkRateLimitAndThrowError({
|
||||
identifier: `eventTypes:list:${ctx.user.id}`,
|
||||
rateLimitingType: "common",
|
||||
});
|
||||
return await prisma.eventType.findMany({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
|
|
Loading…
Reference in New Issue