benoit-bremaud / HappiHub

HappiHub - A platform for organizing and discovering cultural and artistic events. Join the community and explore events happening around you!
https://www.happihub.com
MIT License
1 stars 3 forks source link

feat: implement DELETE /comments/event/:eventId route to delete all c… #209

Closed benoit-bremaud closed 4 months ago

benoit-bremaud commented 4 months ago

feat: implement DELETE /comments/event/:eventId route to delete all comments by event ID

Summary

This pull request implements the DELETE /comments/event/:eventId route that allows the creator of an event to delete all comments by a specific event ID. The route ensures that only the creator of the event can perform the deletion.

Changes Implemented

How to Test

  1. Delete All Comments as Event Creator:

    • Send a DELETE request to http://localhost:5000/comments/event/:eventId with a valid event ID and a token belonging to the creator of the event in the Authorization header.
    • Ensure the response includes { message: 'All comments deleted successfully' }.
  2. No Comments Found:

    • Send a DELETE request to http://localhost:5000/comments/event/:eventId with a valid event ID but no comments for that event.
    • Ensure the response is 404 Not Found.
  3. Unauthorized Deletion Attempt:

    • Send a DELETE request to http://localhost:5000/comments/event/:eventId with a valid event ID and a token from a user who is not the creator of the event.
    • Ensure the response is 403 Forbidden.

Example Request (Event Creator)

DELETE /comments/event/60b8d2956b2e2c001b8f4a8b HTTP/1.1
Host: localhost:5000
Authorization: Bearer <creator_token>

Example Response

{
    "message": "All comments deleted successfully"
}

New Issues Created

Resolves