Fix1#89
Open
divyansh-v15-06 wants to merge 8 commits into
Open
Conversation
Owner
|
@divyansh-v15-06 remove docs/ dir for now, api naming refactoring is planned so these docs would not make sense after that. And also update these apis in the frontend app/ dir. |
Collaborator
Author
|
done |
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.
Description
This PR resolves Issue #41 by implementing the missing API endpoints for editing, deleting, and fetching admin comments. As requested, these endpoints exclusively handle the comment logic and do not interact with or change the status of the posts.
Changes Included:
Added AdminEditComment Handler (PATCH):
Endpoint: PATCH /api/admin/comment/:type/:id/:comment_id
Allows admins to update the text content of their own comments.
Includes authorization checks to verify that the logged-in admin is the author of the comment (matched via email).
Added AdminDeleteComment Handler (DELETE):
Endpoint: DELETE /api/admin/comment/:type/:id/:comment_id
Allows admins to delete their own comments.
Includes the same authorization checks to prevent admins from deleting comments authored by others.
Added AdminGetComments Handler (GET):
Endpoint: GET /api/admin/comments
Fetches all comments authored by the currently logged-in admin across all posts. This resolves the AdminGetComments TODO left in the code.
Routing Updates: Successfully wired up the PATCH, DELETE, and GET endpoints in routes/admin.go and verified they are protected by the IsAuthenticated middleware.
Testing:
Passed the entire existing backend test suite (go test -v ./test/...).
Verified that comment ownership logic correctly restricts access to PATCH and DELETE actions.