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: delete blog like #967

Merged
merged 6 commits into from
Aug 24, 2024

Conversation

chimeziriobioha
Copy link
Contributor

Description:

An endpoint to enable users who previously liked a blog post to remove the like.

Related Issue:

[FEAT]: Endpoint To Delete Blog Like #965

Motivation and Context

Readers should be able to remove like from a particular post after adding one, if they posted it in error or just changed their mind.

How Has This Been Tested?

  • Unit Tests: Added tests to validate successful and failed requests as expected.
  • Test Environment: Mocked database; to avoid interference with the production environment.
  • Postman: Validation test has also been run on postman API tester, with screenshots attached below.

Screenshots:

Delete Blog Like Success

delete blog like success

Non Owner Request

delete blog like not owner

Blog Like Not Available

delete blog like not found

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Added Fix:

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

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

api/v1/routes/blog.py Show resolved Hide resolved
api/v1/services/blog.py Show resolved Hide resolved
@johnson-oragui johnson-oragui merged commit 44defcd into hngprojects:dev Aug 24, 2024
1 check passed
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.

2 participants