Skip to content

Adds idempotent post like/unlike API#699

Merged
davidmz merged 5 commits into
stablefrom
idempotent-likes
Apr 27, 2026
Merged

Adds idempotent post like/unlike API#699
davidmz merged 5 commits into
stablefrom
idempotent-likes

Conversation

@davidmz

@davidmz davidmz commented Apr 26, 2026

Copy link
Copy Markdown
Member

Introduces new PUT and DELETE endpoints for liking and unliking posts, enhancing API robustness and client-side control.

These new endpoints offer true idempotency:

  • PUT /v1/posts/:postId/like likes a post and consistently returns 200 OK, even if the post is already liked.
  • DELETE /v1/posts/:postId/like removes a like and consistently returns 200 OK, even if the post is not liked.

Both new and existing POST endpoints now accept an optional operation-id header for client-side deduplication. This operation-id is returned in the meta field of the API response.

Realtime like:new and like:remove events are updated to include meta.operationId. For privacy, this ID is only visible to the user who initiated the action and appears as null for other subscribers.

davidmz added 5 commits April 26, 2026 13:59
Adds `PUT /posts/:postId/like` and `DELETE /posts/:postId/like` to provide idempotent actions for liking and unliking posts
Introduces an `operationId` parameter to the `addLike` and `removeLike` methods, which is then propagated through the pubsub system.
Adds documentation for the new PUT and DELETE like endpoints, the operation-id header, and related changes to realtime events.
Adds `PUT /v2/comments/:commentId/like` and `DELETE /v2/comments/:commentId/like` to provide idempotent actions for comment likes. Like the post-level equivalents, these endpoints accept an `operation-id` header for client-side deduplication and propagate it through realtime events to the action performer.
@davidmz davidmz merged commit 7a713d8 into stable Apr 27, 2026
0 of 12 checks passed
@davidmz davidmz deleted the idempotent-likes branch April 29, 2026 16:07
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.

1 participant