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]: Endpoint To Delete Blog Dislike #966

Open
9 tasks
chimeziriobioha opened this issue Aug 24, 2024 · 0 comments
Open
9 tasks

[FEAT]: Endpoint To Delete Blog Dislike #966

chimeziriobioha opened this issue Aug 24, 2024 · 0 comments

Comments

@chimeziriobioha
Copy link
Contributor

chimeziriobioha commented Aug 24, 2024

Description:

Implement an endpoint to enable users who previously disliked a blog post to remove the dislike.

Acceptance Criteria:

  • It should be a PROTECTED endpoint, requiring authentication.
  • It should be a DELETE request at /api/v1/blogs/dislikes/{blog_dislike_id}.
  • It should remove BlogDislke from the database and return appropriate message to the user.
  • It should allow ONLY the user who posted the dislike to delete it.

Purpose

To enable a blog post readers to remove dislike from any particular post after adding one.

Requirements

  • Develop server-side logic to delete dislike from a blog post following acceptance criteria above
  • Test the endpoint for correctness and accuracy.

Expected Outcome:

Blog readers should be able to remove dislike from a blog post if they posted it in error or just changed their mind.


Tasks:

  • Create endpoint (DELETE: /api/v1/blogs/dislikes/{blog_dislike_id}) to handle request.
  • Validate blog_dislike_id, access BlogDislike object and confirm that requester created it.
  • Delete the BlogDislike object from the database
  • Return self explanatory success response if request goes well, or failure response, if it doesn't.
  • Write comprehensive unit tests for the endpoint and operation.

Example Request [With Auth Token]:

curl -X DELETE {rootdomain}/api/v1/blogs/dislikes/{blog_dislike_id} \
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
     -d ....

Response [Success]:

status_code: 204

Response Body [Errors]:

  • Unrecognized user: { "status_code": 401, "message": "Could not validate credentials." }
  • Not the blog dislike owner: { "status_code": 401, "message": "Insufficient permission" }
  • Invalid blog ID: { "status_code": 404, "message": "BlogDislike does not exist." }***

Testing:

  • Write end-to-end backend unit tests for the delete blog dislike process.
  • Test all possible outcomes and reactions for like (e.g., successful, failed, etc).

Added Fix:

Enable /api/v1/blogs/{blog_id}/dislike endpoint to automatically remove existing like by the current_user before creating new dislike, and vice versa with the /api/v1/blogs/{blog_id}/like endpoint.

This is important if a user clicks the dislike button after already clicking the like button without first removing the like. Otherwise, the database will have unintended records of both like and dislike for the same user on the same blog.

@chimeziriobioha chimeziriobioha changed the title [FEAT]: Endpoint To Delete BlogDislike [FEAT]: Endpoint To Delete Blog Dislike Aug 24, 2024
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

No branches or pull requests

1 participant