Add post approval and rejection endpoints with email notification#111
Add post approval and rejection endpoints with email notification#111
Conversation
Introduced ApprovePost and RejectPost endpoints in PostsController for admins to update post status. PostService now sends an email notification to the seller when a post is approved.
|
You've used up your 5 PR reviews for this month under the Korbit Starter Plan. You'll get 5 more reviews on July 30th, 2025 or you can upgrade to Pro for unlimited PR reviews and enhanced features in your Korbit Console. |
|
Caution Review failedThe pull request is closed. WalkthroughThe changes add email notifications to the post status update process, sending approval or rejection emails to sellers. A new admin-only PATCH endpoint Changes
Sequence Diagram(s)sequenceDiagram
participant Admin
participant PostsController
participant PostService
participant IMailService
participant Seller
Admin->>PostsController: PATCH /posts/adjustStatus (PostId, Status, Reason?)
PostsController->>PostService: UpdatePostStatus(PostId, Status, Reason)
PostService->>PostService: Retrieve post with seller info
PostService->>PostService: Update post status
alt Status is Active
PostService->>IMailService: Send approval email to Seller
else Status is Rejected and Reason provided
PostService->>IMailService: Send rejection email with reason to Seller
end
PostService-->>PostsController: Return updated post DTO
PostsController-->>Admin: Return updated post response
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
Dentizone.Application/Services/PostService.cs (1)
2-2: Remove unused import.The
Azure.Corenamespace is imported but not used in this file.-using Azure.Core;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Dentizone.Application/Services/PostService.cs(3 hunks)Dentizone.Presentaion/Controllers/PostsController.cs(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
Dentizone.Presentaion/Controllers/PostsController.cs (2)
Learnt from: gitnasr
PR: dentizone/api#104
File: Dentizone.Presentaion/Controllers/ReviewController.cs:24-24
Timestamp: 2025-06-29T09:03:23.566Z
Learning: In the Dentizone application, users cannot edit reviews once they are submitted. Only admins can update or delete reviews, likely for moderation purposes. This means review updates and deletions should be restricted to admin-only authorization rather than ownership-based authorization.
Learnt from: gitnasr
PR: dentizone/api#104
File: Dentizone.Presentaion/Controllers/PostsController.cs:60-61
Timestamp: 2025-06-29T09:04:16.858Z
Learning: The Dentizone application uses global middleware to handle exceptions, which means controller methods don't need individual try-catch blocks. Service layer exceptions are centrally caught and translated to appropriate HTTP responses through this middleware.
- Updated `IPostService` to include a nullable `reason` parameter in `UpdatePostStatus`. - Modified `PostService` to implement the new parameter and added `NotifySellerAsync` for email notifications. - Replaced `ApprovePost` and `RejectPost` methods in `PostsController` with a unified `AdjustStatus` method using `UpdatePostStateDto`. - Introduced `UpdatePostStateDto` to encapsulate post status update parameters. - Cleaned up unused `using` directives in `PostService` and `PostsController`.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Dentizone.Application/DTOs/Post/UpdatePostStateDto.cs(1 hunks)Dentizone.Application/Interfaces/IPostService.cs(1 hunks)Dentizone.Application/Services/PostService.cs(4 hunks)Dentizone.Presentaion/Controllers/PostsController.cs(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- Dentizone.Application/DTOs/Post/UpdatePostStateDto.cs
🚧 Files skipped from review as they are similar to previous changes (2)
- Dentizone.Presentaion/Controllers/PostsController.cs
- Dentizone.Application/Services/PostService.cs
🧰 Additional context used
🧬 Code Graph Analysis (1)
Dentizone.Application/Interfaces/IPostService.cs (1)
Dentizone.Application/DTOs/Post/PostViewDTO.cs (1)
PostViewDto(5-20)
| Task<List<PostViewDto>> Search(UserPreferenceDto userPreferenceDto); | ||
| Task<List<Domain.Entity.Post>> ValidatePosts(List<string> postIds); | ||
| Task<PostViewDto> UpdatePostStatus(string postId, PostStatus status); | ||
| Task<PostViewDto> UpdatePostStatus(string postId, PostStatus status, string? reason); |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Good addition for enhanced post status communication.
The optional reason parameter is a sensible enhancement that allows providing explanations when updating post status, particularly useful for rejections. The nullable string type is appropriate for this optional parameter.
Note that this is a breaking change to the interface - ensure all implementations of IPostService have been updated to include this parameter.
🏁 Script executed:
#!/bin/bash
# Description: Verify all implementations of IPostService have been updated with the new signature
# Expected: All implementations should include the reason parameter
# Search for classes implementing IPostService
ast-grep --pattern 'class $_ : $$$IPostService$$$'
# Search for UpdatePostStatus method implementations
ast-grep --pattern 'UpdatePostStatus($$$) {'Length of output: 99
I’ll double-check all C# files to find where IPostService is referenced, which classes implement it, and verify each UpdatePostStatus signature.
🏁 Script executed:
#!/bin/bash
echo "1) All references to IPostService:"
rg -n --no-heading --color never --glob '*.cs' "IPostService"
echo
echo "2) Classes implementing IPostService:"
rg -nP --no-heading --color never --glob '*.cs' "class\s+\w+\s*:\s*.*IPostService"
echo
echo "3) All UpdatePostStatus definitions/calls:"
rg -n --no-heading --color never --glob '*.cs' "UpdatePostStatus"Length of output: 1981
Action Required: Update all UpdatePostStatus invocations to include the new reason argument
The nullable reason parameter is a sensible enhancement for communicating rejection details, but existing calls need to be updated to avoid breakage. Specifically:
- Dentizone.Application/Services/OrderService.cs
- Line 75:
await postService.UpdatePostStatus(post.Id, PostStatus.Active); - Line 170:
await postService.UpdatePostStatus(post.Id, PostStatus.Sold);
→ Add a third argument (e.g.nullor a message) for the newreasonparameter.
- Line 75:
Verify there are no other two-argument calls to UpdatePostStatus across the codebase.
🤖 Prompt for AI Agents
In Dentizone.Application/Services/OrderService.cs at lines 75 and 170, the calls
to UpdatePostStatus currently pass only two arguments, but the method signature
now requires a third nullable reason parameter. Update these calls by adding a
third argument, such as null or an appropriate message string, to match the new
method signature. Also, search the entire codebase for any other calls to
UpdatePostStatus with only two arguments and update them similarly to prevent
compilation errors.
- Added using directive for Dentizone.Application.DTOs.Payment. - Updated CancelOrderAsync to include reason for post status change. - Modified email notifications for order cancellation and new orders for consistency. - Improved code readability by removing unnecessary line breaks and reformatting method calls.
|



Introduced ApprovePost and RejectPost endpoints in PostsController for admins to update post status. PostService now sends an email notification to the seller when a post is approved.
Summary by CodeRabbit
New Features
Enhancements