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: update a comment #964

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

idowuseyi
Copy link
Contributor

What does the PR do?

This PR introduces new API endpoints to update comments. It includes server-side logic for handling comment update, along with appropriate validation and error handling.

How should this be manually tested?

To Update a Comment:

Send a PATCH request to /api/v1/comments/update/:comment_id with a valid UpdateCommentDto payload and a valid comment_id in the request.
Example:

PATCH /api/v1/comments/update/:comment_id

{
"content": "This is the update to the original comment"
}

Successful Response

On a successful comment update, the API should return a 200 SUCCESS status code.

{
      "status": "status_code",
      "message": "Comment updated successfully",
      "data": {
            "id": "84488317-234b-41b5-a2d1-07d47a50be8e",
            "created_at": "2024-08-08T06:27:40.309Z",
            "updated_at": "2024-08-08T06:59:59.030Z",
            "comment": "I just update this comment now",
            "model_id": "1234",
            "model_type": "post"
            }
      "commentedBy" : "John Smith"
}

Error Handling:

When the current user is not authourized:

{
          "status": "error",
          "message": "User not authorized",
          "status_code": "401",
 }

When the current user is not found:

{
          "status": "error",
          "message": "User nof found",
          "status_code": "404",
 }

Error During coment update

If the comment creation is not successful:

{
  "status": "Error",
  "message": "Error creating comment",
  "status_code": 500
}

Checklist of what has been done

  • [X ] Define API endpoint to update comment.
  • [X ] Validate and handle authentication token.
  • [ X] Implement logic to update a comment.
  • [ X] Handle success and error responses.
  • [ X] Test Successful response

API Test Screenshot

Screenshot from 2024-08-08 07-59-37

Jest Test Screenshot

Screenshot from 2024-08-07 15-46-24

Referenced Linear Ticket: Ticket-Link
Referenced Issue: Link to Issue

@olika-ashley
Copy link

Update branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants