Restrict guest CSV comment export in UI and fix lint/typecheck cleanup in comment APIs

This commit is contained in:
Yusuf İpek
2026-02-24 15:03:42 +03:00
parent 449433a08a
commit 4083651025
4 changed files with 22 additions and 16 deletions
+6 -2
View File
@@ -243,7 +243,9 @@ export async function PATCH(request: NextRequest, { params }: RouteParams) {
}, },
}); });
const { guestIdentityId: _updatedGuestIdentityId, ...updatedCommentData } = updatedComment; const updatedCommentData = Object.fromEntries(
Object.entries(updatedComment).filter(([key]) => key !== 'guestIdentityId')
);
const response = successResponse({ const response = successResponse({
...updatedCommentData, ...updatedCommentData,
canEdit: canEditOwnContent, canEdit: canEditOwnContent,
@@ -255,7 +257,9 @@ export async function PATCH(request: NextRequest, { params }: RouteParams) {
&& !reply.authorId && !reply.authorId
&& !!reply.guestIdentityId && !!reply.guestIdentityId
&& reply.guestIdentityId === guestIdentityId; && reply.guestIdentityId === guestIdentityId;
const { guestIdentityId: _replyGuestIdentityId, ...replyData } = reply; const replyData = Object.fromEntries(
Object.entries(reply).filter(([key]) => key !== 'guestIdentityId')
);
return { return {
...replyData, ...replyData,
canEdit: canEditReply, canEdit: canEditReply,
@@ -362,7 +362,9 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
: !!viewerGuestIdentityId : !!viewerGuestIdentityId
&& !!comment.guestIdentityId && !!comment.guestIdentityId
&& comment.guestIdentityId === viewerGuestIdentityId; && comment.guestIdentityId === viewerGuestIdentityId;
const { guestIdentityId: _guestIdentityId, ...commentData } = comment; const commentData = Object.fromEntries(
Object.entries(comment).filter(([key]) => key !== 'guestIdentityId')
);
const response = successResponse({ const response = successResponse({
...commentData, ...commentData,
+11 -11
View File
@@ -138,12 +138,12 @@ export async function GET(request: NextRequest, { params }: RouteParams) {
&& !!comment.guestIdentityId && !!comment.guestIdentityId
&& comment.guestIdentityId === viewerGuestIdentityId; && comment.guestIdentityId === viewerGuestIdentityId;
const canDeleteComment = canEditComment || isProjectOwner; const canDeleteComment = canEditComment || isProjectOwner;
const { const replies = comment.replies;
authorId: _commentAuthorId, const commentData = Object.fromEntries(
guestIdentityId: _commentGuestIdentityId, Object.entries(comment).filter(
replies, ([key]) => key !== 'authorId' && key !== 'guestIdentityId' && key !== 'replies'
...commentData )
} = comment; );
return { return {
...commentData, ...commentData,
@@ -156,11 +156,11 @@ export async function GET(request: NextRequest, { params }: RouteParams) {
&& !!reply.guestIdentityId && !!reply.guestIdentityId
&& reply.guestIdentityId === viewerGuestIdentityId; && reply.guestIdentityId === viewerGuestIdentityId;
const canDeleteReply = canEditReply || isProjectOwner; const canDeleteReply = canEditReply || isProjectOwner;
const { const replyData = Object.fromEntries(
authorId: _replyAuthorId, Object.entries(reply).filter(
guestIdentityId: _replyGuestIdentityId, ([key]) => key !== 'authorId' && key !== 'guestIdentityId'
...replyData )
} = reply; );
return { return {
...replyData, ...replyData,
canEdit: canEditReply, canEdit: canEditReply,
+2 -2
View File
@@ -3551,12 +3551,12 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi
variant="ghost" variant="ghost"
size="icon" size="icon"
className="h-8 w-8" className="h-8 w-8"
disabled={!activeVersion || isExportingCsv || isExportingPdf} disabled={!activeVersion || isGuest || isExportingCsv || isExportingPdf}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
handleExportComments('csv'); handleExportComments('csv');
}} }}
title="Download comments as CSV" title={isGuest ? 'CSV export requires an authenticated account' : 'Download comments as CSV'}
> >
{isExportingCsv ? <Loader2 className="h-4 w-4 animate-spin" /> : <Download className="h-4 w-4" />} {isExportingCsv ? <Loader2 className="h-4 w-4 animate-spin" /> : <Download className="h-4 w-4" />}
</Button> </Button>