Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Implement Endpoint for Updating a Comment on a Blog #406

Open
YastecHub opened this issue Feb 27, 2025 · 0 comments · May be fixed by #432
Open

[Feat] Implement Endpoint for Updating a Comment on a Blog #406

YastecHub opened this issue Feb 27, 2025 · 0 comments · May be fixed by #432
Assignees
Labels

Comments

@YastecHub
Copy link

YastecHub commented Feb 27, 2025

Description

Develop an endpoint to allow users to update their comments on a blog post. The endpoint should validate that the comment exists, that the user owns the comment, and then update the content while preserving the original creation date. The response should return appropriate status codes based on different validation scenarios.

Requirements

  • Method: PUT
  • URL: /api/v1/posts/{blogId}/comments/{commentId}
  • Headers: Content-Type: application/json

json

{
  "content": "Updated comment text"
}

Responses

✅ Success (200 OK)

json

{
  "message": "Comment updated successfully.",
  "success": true,
  "data": {
    "commentId": "uuid",
    "content": "Updated comment text",
    "updatedAt": "timestamp"
  }
}

❌ Errors

  • 400 Bad Request: Invalid or empty content.
  • 403 Forbidden: User is not authorized to update this comment.
  • 404 Not Found: Blog post or comment does not exist.
  • 500 Internal Server Error: Unexpected failure.

Acceptance Criteria

  • Validate that the blogId and commentId exist in the database.
  • Ensure only the comment owner can update their comment.
  • Update the content field while maintaining the CreatedAt timestamp.
  • Return the correct response and status codes.

Unit Tests

✅ Validate that the content is not empty or invalid.
✅ Ensure only the comment owner can update the comment.
✅ Check that nonexistent comments return a 404.
✅ Verify that the comment is correctly updated in the database.
✅ Ensure that the correct response status codes are returned.

@YastecHub YastecHub changed the title [Feat] Implement Endpoint to Add User Region - C# [Feat] Implement Endpoint to Add User Region Feb 27, 2025
@YastecHub YastecHub changed the title [Feat] Implement Endpoint to Add User Region [Feat] Implement Endpoint for Updating a Comment on a Blog Feb 27, 2025
@YastecHub YastecHub linked a pull request Mar 1, 2025 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants