refactor(community): replace follow/unfollow POST+DELETE pairs with …#53
Merged
Merged
Conversation
…idempotent PUT upsert
Consolidate the eight follow endpoints (topic, user, post, community) into four
idempotent PUT upserts driven by a `{ "status": "Followed" | "Unfollowed" }` body,
so a single RESTful call sets the desired follow state.
- Endpoints: PUT /api/me/follows/{topics,users,posts}/{id} and
PUT /api/community/communities/{id}/follow; drop manual 401 guards (auth is
enforced by RequireAuthorization + defensive NotAuthenticated)
- Add SetTopicFollow/SetUserFollow/SetPostFollow/SetCommunityFollow commands;
delete the 8 Follow*/Unfollow* command folders
- Standardize all follow handlers on Response<VoidData> + MessageFactory +
ToHttpResult (§A); add FollowStatus enum
- Self-follow now returns a clean 400 (CANNOT_FOLLOW_SELF / ERR144, localized ar+en)
- Topic/Post/User targets return 404 when the target does not exist
- Add in-memory-test-safe AnyAsyncEither / FirstOrDefaultAsyncEither helpers
- Rewrite unit tests as SetFollowCommandHandlerTests; update integration 401 tests to PUT
BREAKING CHANGE: follow/unfollow no longer use POST/DELETE. Clients must call
PUT with a `status` body instead.
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.
Summary
Refactored community follow APIs to use idempotent
PUTupserts instead of separatePOST/DELETEfollow-unfollow endpoints.Changes
PUTendpointsSetTopic/User/Post/CommunityFollowcommandsFollowStatusenum (Followed/Unfollowed)Response<VoidData>,MessageFactory, andToHttpResult404handling for missing targetsCANNOT_FOLLOW_SELF/ERR144)Follow*/Unfollow*command foldersPUTBREAKING CHANGE
Clients must now send:
{ "status": "Followed" | "Unfollowed" }using
PUTinstead ofPOST/DELETE.