Skip to content

refactor(community): replace follow/unfollow POST+DELETE pairs with …#53

Merged
Rashed99Azm merged 1 commit into
develop-backendfrom
feat/comunitty-home-enhancments
Jun 11, 2026
Merged

refactor(community): replace follow/unfollow POST+DELETE pairs with …#53
Rashed99Azm merged 1 commit into
develop-backendfrom
feat/comunitty-home-enhancments

Conversation

@Rashed99Azm

Copy link
Copy Markdown
Collaborator

Summary

Refactored community follow APIs to use idempotent PUT upserts instead of separate POST/DELETE follow-unfollow endpoints.

Changes

  • Replaced 8 follow/unfollow endpoints with 4 unified PUT endpoints
  • Added SetTopic/User/Post/CommunityFollow commands
  • Introduced FollowStatus enum (Followed / Unfollowed)
  • Standardized handlers on Response<VoidData>, MessageFactory, and ToHttpResult
  • Added proper 404 handling for missing targets
  • Added clean self-follow validation (CANNOT_FOLLOW_SELF / ERR144)
  • Removed legacy Follow* / Unfollow* command folders
  • Added test-safe async query helpers
  • Updated unit and integration tests to use PUT

BREAKING CHANGE

Clients must now send:

{
  "status": "Followed" | "Unfollowed"
}

using PUT instead of POST/DELETE.

…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.
@Rashed99Azm Rashed99Azm merged commit de9587e into develop-backend Jun 11, 2026
2 of 11 checks 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