Fix: Align domain contact duplication logic and notifications#2791
Open
OlegPhenomenon wants to merge 4 commits into
Open
Fix: Align domain contact duplication logic and notifications#2791OlegPhenomenon wants to merge 4 commits into
OlegPhenomenon wants to merge 4 commits into
Conversation
Contributor
This commit refines the contact duplication checks and notification messages for domain creation and updates, ensuring consistency and addressing a bug in domain updates.
**Key Changes:**
* **Consistent Duplicate Contact Handling:**
* The `check_for_cross_role_duplicates`, `remove_duplicate_contacts`, and `duplicate_contact?` methods are now more closely aligned between `DomainCreate` and `DomainUpdate` interactors.
* `DomainUpdate` now correctly uses `admin_contact_ids=` and `tech_contact_ids=` to assign filtered contacts. This resolves a `PG::UniqueViolation` error that occurred when trying to re-associate existing contacts using `_attributes=` methods.
* The `duplicate_contact?` method in `DomainCreate` was updated to match `DomainUpdate`, primarily checking for semantic duplicates based on attributes (name, ident, email, phone) rather than also including a `contact.code` check, which is more suitable for cross-role duplication.
* **Standardized Notification Messages:**
* The `notify_about_removed_duplicates` method in both interactors now generates a more concise message: ". [Role] contact [CODE] was discarded as duplicate;" for each discarded contact.
* This message is appended to `domain.skipped_domain_contacts_validation`.
* **EPP & REPP Response Updates:**
* The `message` method in `Repp::V1::DomainsController` now correctly appends `domain.skipped_domain_contacts_validation` to the "Command completed successfully" message, ensuring it appears in REPP JSON responses for both create and update.
* The EPP XML views (`app/views/epp/domains/create.xml.builder` and `app/views/epp/domains/success.xml.builder`) are updated to dynamically include `domain.skipped_domain_contacts_validation` in the `<msg>` tag.
* **Model Attribute:**
* Added `skipped_domain_contacts_validation` as a string attribute to the `Domain` model to store these notification messages.
* **Test Refinements (Implicit):**
* The related test suite for domain updates (`test/integration/epp/domain/base_test.rb`) was being updated to reflect these logic changes and assert the correct notification messages.
These changes improve the robustness and consistency of contact management during domain operations, providing clearer feedback to users about discarded duplicate contacts.
70a5ab0 to
5224824
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





Close #2788
This commit refines the contact duplication checks and notification messages for domain creation and updates, ensuring consistency and addressing a bug in domain updates.
Key Changes:
Consistent Duplicate Contact Handling:
check_for_cross_role_duplicates,remove_duplicate_contacts, andduplicate_contact?methods are now more closely aligned betweenDomainCreateandDomainUpdateinteractors.DomainUpdatenow correctly usesadmin_contact_ids=andtech_contact_ids=to assign filtered contacts. This resolves aPG::UniqueViolationerror that occurred when trying to re-associate existing contacts using_attributes=methods.duplicate_contact?method inDomainCreatewas updated to matchDomainUpdate, primarily checking for semantic duplicates based on attributes (name, ident, email, phone) rather than also including acontact.codecheck, which is more suitable for cross-role duplication.Standardized Notification Messages:
notify_about_removed_duplicatesmethod in both interactors now generates a more concise message: ". [Role] contact [CODE] was discarded as duplicate;" for each discarded contact.domain.skipped_domain_contacts_validation.EPP & REPP Response Updates:
messagemethod inRepp::V1::DomainsControllernow correctly appendsdomain.skipped_domain_contacts_validationto the "Command completed successfully" message, ensuring it appears in REPP JSON responses for both create and update.app/views/epp/domains/create.xml.builderandapp/views/epp/domains/success.xml.builder) are updated to dynamically includedomain.skipped_domain_contacts_validationin the<msg>tag.Model Attribute:
skipped_domain_contacts_validationas a string attribute to theDomainmodel to store these notification messages.Test Refinements (Implicit):
test/integration/epp/domain/base_test.rb) was being updated to reflect these logic changes and assert the correct notification messages.These changes improve the robustness and consistency of contact management during domain operations, providing clearer feedback to users about discarded duplicate contacts.