mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
🔒️ Rate limit comments (#1372)
This commit is contained in:
parent
6cfb56d4bc
commit
251ee76979
2 changed files with 16 additions and 8 deletions
|
@ -15,6 +15,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@rallly/ui/dropdown-menu";
|
||||
import { useToast } from "@rallly/ui/hooks/use-toast";
|
||||
import { Icon } from "@rallly/ui/icon";
|
||||
import { Input } from "@rallly/ui/input";
|
||||
import { Textarea } from "@rallly/ui/textarea";
|
||||
|
@ -77,13 +78,6 @@ function NewCommentForm({
|
|||
|
||||
const queryClient = trpc.useUtils();
|
||||
|
||||
const addComment = trpc.polls.comments.add.useMutation({
|
||||
onSuccess: () => {
|
||||
queryClient.polls.comments.invalidate();
|
||||
posthog?.capture("created comment");
|
||||
},
|
||||
});
|
||||
|
||||
const session = useUser();
|
||||
|
||||
const { register, reset, control, handleSubmit, formState } =
|
||||
|
@ -93,7 +87,20 @@ function NewCommentForm({
|
|||
content: "",
|
||||
},
|
||||
});
|
||||
const { toast } = useToast();
|
||||
|
||||
const addComment = trpc.polls.comments.add.useMutation({
|
||||
onSuccess: () => {
|
||||
queryClient.polls.comments.invalidate();
|
||||
posthog?.capture("created comment");
|
||||
},
|
||||
onError: (error) => {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message,
|
||||
});
|
||||
},
|
||||
});
|
||||
return (
|
||||
<form
|
||||
className="w-full space-y-2.5"
|
||||
|
|
|
@ -5,7 +5,7 @@ import { absoluteUrl } from "@/utils/absolute-url";
|
|||
import { getEmailClient } from "@/utils/emails";
|
||||
import { createToken } from "@/utils/session";
|
||||
|
||||
import { publicProcedure, router } from "../../trpc";
|
||||
import { publicProcedure, rateLimitMiddleware, router } from "../../trpc";
|
||||
import { DisableNotificationsPayload } from "../../types";
|
||||
|
||||
export const comments = router({
|
||||
|
@ -27,6 +27,7 @@ export const comments = router({
|
|||
});
|
||||
}),
|
||||
add: publicProcedure
|
||||
.use(rateLimitMiddleware)
|
||||
.input(
|
||||
z.object({
|
||||
pollId: z.string(),
|
||||
|
|
Loading…
Add table
Reference in a new issue