diff --git a/SharpbinV3.Client/src/lib/components/PasteCommentItem.svelte b/SharpbinV3.Client/src/lib/components/PasteCommentItem.svelte
index aca089b..431b72d 100644
--- a/SharpbinV3.Client/src/lib/components/PasteCommentItem.svelte
+++ b/SharpbinV3.Client/src/lib/components/PasteCommentItem.svelte
@@ -209,26 +209,28 @@
>
{replyOpen ? 'Cancel' : 'Reply'}
-
-
- {#if hasRole($user.roles, 4)}
+ {#if node.author?.uuid === $user.uuid || hasRole($user.roles, 4) || hasRole($user.roles, 2)}
+
- {/if}
-
+ {#if hasRole($user.roles, 4) || hasRole($user.roles, 2)}
+
+ {/if}
+
+ {/if}
{/if}
diff --git a/SharpbinV3.Server/Services/CommentService.cs b/SharpbinV3.Server/Services/CommentService.cs
index 884eaa0..60a6cf9 100644
--- a/SharpbinV3.Server/Services/CommentService.cs
+++ b/SharpbinV3.Server/Services/CommentService.cs
@@ -78,7 +78,26 @@ namespace SharpbinV3.Server.Services
public async Task HardDeleteComment(Comment comment)
{
- _db.Comments.Remove(comment);
+ var commentIdsToDelete = new HashSet { comment.Id };
+ var currentLevelIds = new List { comment.Id };
+
+ while (currentLevelIds.Count != 0)
+ {
+ var childIds = await _db
+ .Comments.Where(c => c.ParentCommentID.HasValue && currentLevelIds.Contains(c.ParentCommentID.Value))
+ .Select(c => c.Id)
+ .ToListAsync();
+
+ currentLevelIds = [];
+ foreach (var childId in childIds)
+ {
+ if (commentIdsToDelete.Add(childId))
+ currentLevelIds.Add(childId);
+ }
+ }
+
+ var commentsToDelete = await _db.Comments.Where(c => commentIdsToDelete.Contains(c.Id)).ToListAsync();
+ _db.Comments.RemoveRange(commentsToDelete);
var result = await _db.SaveChangesAsync();
return result > 0;
}