-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Implement message reporting feature #78
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
Conversation
- Added ReportMessageCommand and ReportMessageResponse records for reporting messages. - Created ReportMessageCommandHandler to handle reporting logic, including user authentication and validation. - Implemented ReportMessageCommandValidator for input validation. - Developed IReportRepository interface and ReportRepository implementation for data operations. - Configured Report entity and its database mappings. - Updated MessageController to include endpoint for reporting messages. - Added necessary migrations for the new Report table in the database.
|
Caution Review failedThe pull request is closed. WalkthroughThis PR introduces a comprehensive message reporting feature following the CQRS pattern. It includes a command and handler for submitting reports, domain models for Report entities with a ReportCategory enum, repository abstractions and implementations, EF Core configuration with database migrations, and a new API endpoint for reporting messages. Changes
Sequence DiagramsequenceDiagram
actor Client
participant API as MessageController
participant Handler as ReportMessageCommandHandler
participant CurrentUserSvc as ICurrentUserService
participant MsgRepo as IMessageRepository
participant ReportRepo as IReportRepository
participant DB as Database
Client->>API: POST /messages/{id}/report<br/>(ReportMessageCommand)
API->>Handler: Handle(command)
Handler->>CurrentUserSvc: GetCurrentUser()
CurrentUserSvc-->>Handler: User or null
alt User Not Authenticated
Handler-->>API: Unauthorized Error
API-->>Client: 401 Response
end
Handler->>MsgRepo: GetByIdAsync(MessageId)
MsgRepo->>DB: Query Message
DB-->>MsgRepo: Message or null
alt Message Not Found
Handler-->>API: NotFound Error
API-->>Client: 404 Response
end
alt Current User is Message Sender
Handler-->>API: Validation Error<br/>(Cannot report own message)
API-->>Client: 400 Response
end
Handler->>ReportRepo: GetByMessageIdAsync(MessageId)
ReportRepo->>DB: Query Reports by MessageId
DB-->>ReportRepo: List<Report>
alt Report Already Exists from User
Handler-->>API: Validation Error<br/>(Duplicate report)
API-->>Client: 400 Response
end
Handler->>ReportRepo: AddAsync(newReport)
ReportRepo->>DB: Insert Report
DB-->>ReportRepo: Success
Handler-->>API: Result<ReportMessageResponse>
API-->>Client: 200 Response<br/>(ReportId, MessageId, Category, CreatedAt)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Free 📒 Files selected for processing (15)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
…e-reporting feat: Implement message reporting feature
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.