-
Notifications
You must be signed in to change notification settings - Fork 3
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 support for supplied transmission attachment ID on create/update #1242
feat: Add support for supplied transmission attachment ID on create/update #1242
Conversation
Warning Rate limit exceeded@oskogstad has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 57 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThe pull request introduces significant updates to the Dialogporten API's OpenAPI specification and related classes. Key changes include the addition of Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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
Documentation and Community
|
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.
Actionable comments posted: 6
🧹 Outside diff range comments (2)
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs (1)
Line range hint
1-125
: Consider enhancing error handling and optimizing ID generation.While the overall implementation is solid, consider the following suggestions for further improvement:
Error Handling: Instead of adding errors to the
DomainContext
, consider throwing custom exceptions for each error case. This approach can make error handling more explicit and easier to manage at higher levels of the application.ID Generation: If the IDs for dialogs, activities, transmissions, and attachments are being generated on the client-side, consider moving this responsibility to the server-side. This can help prevent potential ID conflicts and reduce the need for existence checks.
Here's an example of how you might implement server-side ID generation:
public async Task<CreateDialogResult> Handle(CreateDialogCommand request, CancellationToken cancellationToken) { var dialog = _mapper.Map<DialogEntity>(request); // Generate IDs server-side dialog.Id = Guid.NewGuid(); foreach (var activity in dialog.Activities) { activity.Id = Guid.NewGuid(); } foreach (var transmission in dialog.Transmissions) { transmission.Id = Guid.NewGuid(); foreach (var attachment in transmission.Attachments) { attachment.Id = Guid.NewGuid(); } } // Rest of the method remains the same // ... }This approach would eliminate the need for the
EnsureNoExistingUserDefinedIds
method altogether, simplifying the code and improving performance.docs/schema/V1/swagger.verified.json (1)
Line range hint
1-4630
: Consider updating API documentation for new ID fields.The changes to both
CreateDialogTransmissionAttachmentDto
andUpdateDialogTransmissionAttachmentDto
schemas are well-implemented and consistent. They improve the API by allowing for idempotent operations on transmission attachments.To ensure API consumers can make the most of these new features:
- Consider updating any external API documentation to explain the usage and benefits of these new ID fields.
- If there are code examples or client SDKs, they may need to be updated to demonstrate how to use these fields effectively.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
📒 Files selected for processing (8)
- docs/schema/V1/swagger.verified.json (4 hunks)
- src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs (1 hunks)
- src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommandValidator.cs (1 hunks)
- src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs (3 hunks)
- src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/MappingProfile.cs (1 hunks)
- src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs (1 hunks)
- src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommandValidator.cs (1 hunks)
- src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogDto.cs (1 hunks)
🧰 Additional context used
🔇 Additional comments (9)
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs (1)
Line range hint
1-125
: Summary: Approved with suggestions for improvementThe changes made to add support for supplied transmission attachment ID on create/update are well-implemented and consistent with the existing codebase. The new check for existing transmission attachment IDs enhances data integrity and prevents potential duplicates.
Key points:
- The implementation is approved and ready for merging.
- Minor optimization suggested for combining ID checks into a single database query.
- Consider enhancing error handling by using custom exceptions instead of adding to DomainContext.
- Explore the possibility of server-side ID generation to simplify the code and improve performance.
These suggestions aim to further improve the robustness and efficiency of the implementation without blocking the current changes from being merged.
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/MappingProfile.cs (1)
84-84
: LGTM: New mapping allows for transmission attachment ID updates.The new mapping configuration allows the
Id
property to be mapped fromUpdateDialogTransmissionAttachmentDto
toDialogTransmissionAttachment
. This change aligns with the PR objective of adding support for supplied transmission attachment IDs during updates.To ensure all mentioned changes are present, please run the following script:
✅ Verification successful
Verified: Both mapping configurations are present.
All mapping changes mentioned in the review comment are confirmed and align with the PR objectives.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the presence of both mapping changes mentioned in the AI summary # Test 1: Check for UpdateDialogTransmissionAttachmentDto mapping echo "Checking UpdateDialogTransmissionAttachmentDto mapping:" rg "CreateMap<UpdateDialogTransmissionAttachmentDto, DialogTransmissionAttachment>" src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/MappingProfile.cs # Test 2: Check for UpdateDialogTransmissionAttachmentUrlDto mapping echo "Checking UpdateDialogTransmissionAttachmentUrlDto mapping:" rg "CreateMap<UpdateDialogTransmissionAttachmentUrlDto, AttachmentUrl>" src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/MappingProfile.csLength of output: 794
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs (1)
Line range hint
1-424
: Overall, the file demonstrates high-quality implementation.The
UpdateDialogCommandHandler
class is well-structured and includes thorough validation checks for various aspects of the dialog update process. The new addition for checking existing transmission attachment IDs further enhances the robustness of the update operation.Key strengths of this implementation:
- Comprehensive error handling and validation
- Proper use of dependency injection
- Clear separation of concerns in different methods
- Effective use of AutoMapper for object mapping
- Careful handling of entity relationships
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommandValidator.cs (1)
117-120
: Verify consistency of UUID v7 validation across the codebaseThe addition of UUID v7 validation for the
Id
property inUpdateDialogTransmissionAttachmentDtoValidator
is a good practice. To ensure consistency, it's recommended to verify if similar validation is applied to other DTOs that use UUID v7 as identifiers.Run the following script to check for consistent UUID v7 validation across the codebase:
Review the output to ensure that all relevant DTOs with
Id
properties of typeGuid
have consistent UUID v7 validation.src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogDto.cs (1)
513-517
: Verify handling of the new Id property throughout the codebaseThe addition of the
Id
property toUpdateDialogTransmissionAttachmentDto
is a significant change that may affect other parts of the codebase. While it doesn't require changes to other classes in this file, it's crucial to ensure proper handling of this new property when processing transmission attachments.Please run the following script to check for potential impacts:
Review the output to ensure that all relevant parts of the codebase properly handle the new
Id
property, including any mapping configurations, validation logic, and data processing related to transmission attachments.✅ Verification successful
Verified: Proper Handling of the New
Id
PropertyThe addition of the
Id
property toUpdateDialogTransmissionAttachmentDto
is correctly integrated across the codebase. Validators ensure theId
is a valid UUIDv7 and that its timestamp is appropriate. Mapping profiles accurately map theId
to the domain entities, and database migrations accommodate the new property with necessary constraints and relationships. No issues were found in the current implementation.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for usage of UpdateDialogTransmissionAttachmentDto and potential places where the new Id property should be handled. # Search for usages of UpdateDialogTransmissionAttachmentDto echo "Searching for usages of UpdateDialogTransmissionAttachmentDto:" rg --type csharp -A 5 "UpdateDialogTransmissionAttachmentDto" # Search for potential mapping or processing of transmission attachments echo "Searching for potential mapping or processing of transmission attachments:" rg --type csharp -A 10 -e "TransmissionAttachment" -e "transmission.*attachment"Length of output: 137593
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs (2)
70-70
: LGTM: Minor formatting improvementsThe removal of trailing spaces in the XML comments for
Process
andSystemLabel
properties improves code cleanliness. These changes don't affect functionality and are in line with good coding practices.Also applies to: 107-107
Line range hint
1-573
: Summary: Successful implementation of transmission attachment ID supportThe changes in this file successfully implement the support for supplied transmission attachment ID on create/update, as outlined in the PR objectives. The addition of the
Id
property toCreateDialogTransmissionAttachmentDto
allows for idempotent creation of transmission attachments, which can improve system reliability and prevent duplicate entries.The changes are localized and don't affect other parts of the file. They maintain consistency with the existing code style and patterns. The minor formatting improvements in XML comments contribute to better code readability.
Overall, these changes enhance the functionality of the dialog creation process while maintaining the integrity of the existing codebase.
docs/schema/V1/swagger.verified.json (2)
754-760
: LGTM! Good addition for idempotent operations.The new
id
property in theCreateDialogTransmissionAttachmentDto
schema is a welcome addition. It allows for idempotent creation of transmission attachments, which is a best practice in API design. The property is correctly defined as a nullable GUID with a clear description of its purpose.
4099-4105
: LGTM! Consistent implementation for update operations.The addition of the
id
property to theUpdateDialogTransmissionAttachmentDto
schema is consistent with the changes made to the create operation. This ensures a uniform approach to handling transmission attachment IDs across different operations in the API. The property is correctly defined as a nullable GUID with an appropriate description.
...ogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs
Show resolved
Hide resolved
...ogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs
Show resolved
Hide resolved
...Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommandValidator.cs
Show resolved
Hide resolved
...Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommandValidator.cs
Show resolved
Hide resolved
...Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogDto.cs
Show resolved
Hide resolved
...Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs
Show resolved
Hide resolved
....Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/MappingProfile.cs
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
🤖 I have created a release *beep* *boop* --- ## [1.22.0](v1.21.0...v1.22.0) (2024-10-07) ### Features * Add support for supplied transmission attachment ID on create/update ([#1242](#1242)) ([c7bfb07](c7bfb07)) ### Bug Fixes * Only allow legacy HTML on AditionalInfo content ([#1210](#1210)) ([aa4acde](aa4acde)) * **webAPI:** Specifying EndUserId on the ServiceOwner Search endpoint produces 500 - Internal Server error ([#1234](#1234)) ([49c0d34](49c0d34)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Description
Related Issue(s)
Verification
Documentation
docs
-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)Summary by CodeRabbit
New Features
id
properties inCreateDialogTransmissionAttachmentDto
andUpdateDialogTransmissionAttachmentDto
for better management of transmission attachments.Id
properties to ensure they are valid UUID version 7 with past timestamps.Bug Fixes
Documentation
These changes enhance the API's functionality, ensuring better tracking and validation of transmission attachments.