forked from boolean-uk/java-team-dev-server-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem Description
As a logged-in user, I want to like or unlike posts,
i also want to know if i already liked a post.
so that I can interact with posts and see the number of likes update in real time.
Required Changes
- Implement a GET endpoint /posts/{id}/liked to check if the current user already liked.
- The endpoint should verify that the post exists.
- Return true if a row exists, otherwise false
- Implement a POST endpoint /posts/{id}/like to toggle a like on a post.
- The endpoint should verify that the post exists.
- The endpoint should return the updated number of likes for the post.
Handle user clicks as follows:
- Like : insert a new row into the likes table.
- Unlike: remove the row from the likes table.
- Like again: insert the row again.
Acceptance Criteria
A user can only have one active like per post at a time.
Toggling works correctly.
Success response:
- 200 with either the updated post object or { "likes": X }. (POST)
- 200 with liked = true or liked = false (GET)
Error responses:
- 404 if post does not exist.
- 500 for server errors.
Dependencies
- Database table likes must exist (Database migration issue).
- Verify the logged-in user.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Todo