Skip to content

Refactor Post Module: Separate Public Display and Management #328

@armanist

Description

@armanist

Description:
Currently, PostController handles both public post display (listing, single post) and authenticated post management (my posts, create, amend, delete). This mixes responsibilities and can be cleaner.

Proposed Refactor:

1. Controllers:

  • PostController → handles public-facing post display only:

    • posts() – paginated list of posts
    • post() – single post view
  • PostManagementController → handles authenticated management only:

    • myPosts()
    • createFrom(), create()
    • amendForm(), amend()
    • delete(), deleteImage()

2. Service:

Keep a single PostService class to handle all post operations, both read and write.
Methods can stay logically grouped as read vs write internally.

3. Routes:

Public routes remain in PostController.
Authenticated routes are moved to PostManagementController with proper middlewares (Editor, Owner).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions