Adds idempotent post like/unlike API#699
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces new
PUTandDELETEendpoints for liking and unliking posts, enhancing API robustness and client-side control.These new endpoints offer true idempotency:
PUT /v1/posts/:postId/likelikes a post and consistently returns200 OK, even if the post is already liked.DELETE /v1/posts/:postId/likeremoves a like and consistently returns200 OK, even if the post is not liked.Both new and existing
POSTendpoints now accept an optionaloperation-idheader for client-side deduplication. Thisoperation-idis returned in themetafield of the API response.Realtime
like:newandlike:removeevents are updated to includemeta.operationId. For privacy, this ID is only visible to the user who initiated the action and appears asnullfor other subscribers.