-
+
{#if expanded || !isLongComment}
{@html parsedHtml}
@@ -164,7 +186,7 @@
{#if !replyOpen}
@@ -227,6 +269,7 @@
{reactingIds}
{onReact}
{onReply}
+ {deleteCommentAction}
/>
{/each}
diff --git a/SharpbinV3.Client/src/lib/components/PasteComments.svelte b/SharpbinV3.Client/src/lib/components/PasteComments.svelte
index a2a2676..8af95a1 100644
--- a/SharpbinV3.Client/src/lib/components/PasteComments.svelte
+++ b/SharpbinV3.Client/src/lib/components/PasteComments.svelte
@@ -11,6 +11,7 @@
import PasteCommentItem from '$lib/components/PasteCommentItem.svelte';
import { SvelteMap } from 'svelte/reactivity';
import RichTextEditor from './RichTextEditor.svelte';
+ import { openModal } from '$lib/stores/modal';
interface Props {
pasteId: string;
@@ -187,6 +188,52 @@
async function submitTopLevelComment(content: string) {
await postComment(content, null);
}
+
+ async function deleteComment(commentId: number, hardDelete = false): Promise
{
+ errorMessage = '';
+ const token = getToken();
+ if (!token) {
+ errorMessage = 'You must be signed in to delete comments.';
+ return false;
+ }
+
+ const title = hardDelete ? 'Hard delete comment?' : 'Delete comment?';
+ const message = hardDelete
+ ? 'This permanently removes the comment from the thread. This cannot be undone.'
+ : 'This will remove the comment content while preserving the thread structure.';
+ const confirmButtonText = hardDelete ? 'Hard delete' : 'Delete';
+ const ok = await openModal({
+ mode: 'confirm',
+ title,
+ message,
+ confirmButtonText,
+ cancelValue: false
+ });
+ if (!ok) {
+ return false;
+ }
+
+ try {
+ const query = hardDelete ? '?hardDelete=true' : '';
+ const res = await fetch(`/api/paste/${pasteId}/comments/${commentId}${query}`, {
+ method: 'DELETE',
+ headers: {
+ Authorization: `Bearer ${token}`
+ }
+ });
+ if (!res.ok) {
+ const err = await res.json().catch(() => ({}));
+ errorMessage = err?.message || 'Failed to delete comment.';
+ return false;
+ }
+
+ await refreshComments();
+ return true;
+ } catch {
+ errorMessage = 'Failed to delete comment.';
+ return false;
+ }
+ }
diff --git a/SharpbinV3.Server/Controllers/PasteController.cs b/SharpbinV3.Server/Controllers/PasteController.cs
index 4452526..9981e0a 100644
--- a/SharpbinV3.Server/Controllers/PasteController.cs
+++ b/SharpbinV3.Server/Controllers/PasteController.cs
@@ -514,6 +514,40 @@ namespace SharpbinV3.Server.Controllers
);
}
+ [HttpDelete]
+ [Authorize(Policy = "JwtOnly")]
+ [Route("{id}/comments/{commentId}")]
+ public async Task