The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Prevent deleting other users' comments
Tim Wilsonfc423dc5e912
diff --git a/apps/web/lib/actions/partners/delete-partner-comment.ts b/apps/web/lib/actions/partners/delete-partner-comment.tsindex 1cb983201e..476aff3312 100644--- a/apps/web/lib/actions/partners/delete-partner-comment.ts+++ b/apps/web/lib/actions/partners/delete-partner-comment.ts@@ -9,7 +9,7 @@ import { authActionClient } from "../safe-action";export const deletePartnerCommentAction = authActionClient.schema(deletePartnerCommentSchema).action(async ({ parsedInput, ctx }) => {- const { workspace } = ctx;+ const { workspace, user } = ctx;const { commentId } = parsedInput;const programId = getDefaultProgramIdOrThrow(workspace);@@ -18,6 +18,7 @@ export const deletePartnerCommentAction = authActionClientwhere: {id: commentId,programId,+ userId: user.id,},});});diff --git a/apps/web/ui/partners/partner-comments.tsx b/apps/web/ui/partners/partner-comments.tsxindex d9e7cac6b2..2d5801b908 100644--- a/apps/web/ui/partners/partner-comments.tsx+++ b/apps/web/ui/partners/partner-comments.tsx@@ -217,24 +217,22 @@ function CommentCard({<div className="h-4 w-24 animate-pulse rounded bg-neutral-200" />)}</div>- {comment && !isEditing ? (+ {comment && !isEditing && comment.userId === user?.id ? (<Popovercontent={<div className="grid w-full grid-cols-1 gap-px p-2 sm:w-48">- {comment.userId === user?.id && (- <Button- text="Edit comment"- variant="outline"- loading={isUpdating}- disabled={comment.delivered === false}- onClick={async () => {- setOpenPopover(false);- setIsEditing(true);- }}- icon={<PenWriting className="size-4" />}- className="h-9 justify-start px-2 font-medium"- />- )}+ <Button+ text="Edit comment"+ variant="outline"+ loading={isUpdating}+ disabled={comment.delivered === false}+ onClick={async () => {+ setOpenPopover(false);+ setIsEditing(true);+ }}+ icon={<PenWriting className="size-4" />}+ className="h-9 justify-start px-2 font-medium"+ /><Buttontext="Delete comment"variant="danger-outline"