feat(life): allow authors to view and restore their deleted comments

Update backend to return soft-deleted comments to their authors
Add restore endpoint and frontend Undo button for deleted comments
Retain comment body and author information upon deletion
This commit is contained in:
2026-05-04 14:54:00 +08:00
parent b0e2036965
commit 016364a8b8
8 changed files with 286 additions and 44 deletions

View File

@@ -103,6 +103,7 @@ import {
retryEntityDiscussionCommentModeration,
retryLifeCommentModeration,
retryLifePostModeration,
restoreLifeComment,
setLifePostRating,
setLifePostReaction,
updateConfig,
@@ -1419,6 +1420,16 @@ app.delete('/api/life-comments/:id', async (request, reply) => {
return deleted ? reply.code(204).send() : notFound(reply, request);
});
app.post('/api/life-comments/:id/restore', async (request, reply) => {
const user = await requirePermissionWithRateLimits(request, reply, 'life.comments.delete', 'communityWrite');
if (!user) {
return;
}
const { id } = request.params as { id: string };
const comment = await restoreLifeComment(Number(id), user.id);
return comment ? comment : notFound(reply, request);
});
app.post('/api/life-comments/:id/moderation/retry', async (request, reply) => {
const user = await requireAnyPermissionWithRateLimits(
request,