Skip to content
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: Add user report feature for code of conduct violations #1211

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

PcNerd9
Copy link

@PcNerd9 PcNerd9 commented Mar 1, 2025

Description

Implemented a feature where user can report another user for code of conduct violation and a super admin can then retrieve all the reports to make inform decision

Endpoints

Method: POST
URL: /api/v1/reports
Authorization: required.

Request Sample

GET /api/v1/activity-logs/action/login
Authorization: Bearer <admin_token>

AND

Method: GET
URL: /api/v1/reports
Authorization: Admin-only access required.

Request Sample

GET /api/v1/activity-logs/action/login
Authorization: Bearer <admin_token>

Related Issue (Link to issue ticket)

Motivation and Context

  • Provides a mechanism for users to report violations of the platform's code of conduct.
  • Ensures a safer and more respectful environment by allowing users to flag inappropriate behavior or misconduct.
  • Enables admins to review and manage reports through restricted access to the reports, ensuring proper action can be taken.

How Has This Been Tested?

curl -X POST 'http://127.0.0.1:8000/api/v1/reports' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMDY3YzMzYzUtNWY2Yy03ZDA5LTgwMDAtNWYwM2Q0OTU2OTdhIiwiZXhwIjoxNzQxMDI4MjkyLCJ0eXBlIjoiYWNjZXNzIn0.MPqCKlI7ztOngxohoetAoMLCcEZ1qKvh0kEVg0k5D4A'\
-d '{ \
    "reported_user": "067c3730-496a-7fda-8000-05de1ee1c631",\
    "reason": "This person is diturbing me"\
}'


curl -X GET 'http://127.0.0.1:7001/api/v1/reports' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMDY3YzM2MmEtMjdjMS03NTQ4LTgwMDAtM2IyZTlkMDlkOTkwIiwiZXhwIjoxNzQxMDM4MDMxLCJ0eXBlIjoiYWNjZXNzIn0.GLBm8Wjob-T7PL8OmXNh2YNqrdC0owu5cZwG0TeAR58'

Screenshots (if appropriate - Postman, etc):

image
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PcNerd9 and others added 2 commits March 1, 2025 22:55
- Implemented a new Report model for the database to store user reports.
- Created POST /reports endpoint for users to report violations.
- Created GET /reports endpoint to allow admin users to view all reports (restricted access).
- Added necessary validations and error handling for the report submission process.
Signed-off-by: Habeeb Ajayi Olawale <[email protected]>
@PcNerd9 PcNerd9 requested a review from samuelogboye March 2, 2025 06:18
Copy link
Contributor

@joboy-dev joboy-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tests??

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.

3 participants