Let people delete their own comments

Open
#128 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Domain
backend, frontend

Research direction

Start in apps/api/src/controllers/postController.ts and read createComment next to listComments to see how authorship and the post's commentCount are handled, then check apps/api/src/models/Comment.ts for the fields you can authorize against. Add a DELETE /api/comments/:id route with backend tests covering the author, the post author, an admin and a refused third party. On the web side, add the confirm-and-delete button in apps/web/src/pages/PostPage.tsx and reuse the cache helpers in usePosts.ts so the count updates without a reload. Done means npm run typecheck, npm test and lint pass.

Written by the indexing model from the issue text.

Description

api enhancement good first issue web

Difficulty: Beginner to Intermediate · Estimated size: half a day to 1 day

Context

Comments can be listed and created (/api/posts/:id/comments), but there is no way to remove one you wrote by mistake.

Problem or goal

Add deleting a comment. The author, the post's author and admins can delete a comment.

Suggested approach

  • API: DELETE /api/comments/:id, decrement commentCount on the post in the same step, and write a test for each allowed and refused role.
  • Web: a delete button (with a confirm step) on each comment on the post page; update the comment count in all cached lists using the helpers in usePosts.ts.

Where to look

  • apps/api/src/controllers/postController.ts (listComments, createComment)
  • apps/api/src/models/Comment.ts
  • apps/web/src/pages/PostPage.tsx

Acceptance criteria

  • The count never goes below zero or drifts.
  • A person cannot delete someone else's comment unless they own the post or are an admin.
  • The list updates without a reload.

How to work on it

  1. Comment here to claim it, so two people do not do the same work.
  2. Fork the repo and branch from main (feat/short-name or fix/short-name). Setup steps are in docs/DEVELOPMENT.md.
  3. Keep the change focused and add tests for backend logic.
  4. Run npm run typecheck, npm test and npm run lint and npm run format before opening the pull request.
  5. Use a Conventional Commits title (for example feat(web): add bookmarks). More in CONTRIBUTING.md.

Stuck? Ask in this issue. Questions are welcome.


Generated by Claude Code

Dominant language
TypeScript
Stars
6
Forks
6
Avg merge
1h 59m
Merged PRs (30d)
59

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Haseeb-MernStack/commune

All issues in Haseeb-MernStack/commune

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.