-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEAT]: Endpoint to Implement Edit or Update of Comments #1199
base: dev
Are you sure you want to change the base?
Conversation
Resolve conflict |
Commit messages not compliant |
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduce this space here.
|
||
def update_comments(self, db: Session, id: str, content: str): | ||
"""Updates a comment""" | ||
|
||
comment = self.fetch(db=db, id=id) | ||
# Update the fields with the provided schema data | ||
if comment is None: | ||
return None | ||
|
||
# Update the comment's content field | ||
comment.content = content | ||
|
||
# Commit the changes to the database | ||
db.commit() | ||
db.refresh(comment) | ||
|
||
return comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The update_comments method in the service layer is very similar to the existing update method. Consider consolidating them or reusing the update method.
[FEAT]: Endpoint to Implement Edit or Update of Comments #1046
Description
This PR implements an endpoint that allows authenticated users to update their comments.
Acceptance Criteria
/api/v1/comments/{id}
Purpose
To allow users to update their own comments while ensuring proper access control and security.
Requirements
Expected Outcome
Tasks
PATCH
endpoint/api/v1/comments/{id}
to edit a comment.Example Requests [With Auth Token]
PATCH Request:
Response (Success):
Response (Error - Comment Not Found):
Response (Error - Forbidden: No Permission to Edit):
Response (Error - Unauthorized Access: Missing or Invalid Token):
Testing