Skip to content

Conversation

@printminion-co
Copy link

@printminion-co printminion-co commented Nov 10, 2025

TODO:

This pull request introduces robust support for deleting IONOS mailboxes when a user is deleted, improves the detection and configuration checks for IONOS integration, and refactors the IONOS API client usage for clarity and maintainability. It also adds comprehensive tests for the new configuration logic and updates naming for consistency.

IONOS Integration Improvements

  • Added isIonosIntegrationEnabled and isMailConfigEnabled methods to IonosConfigService to centralize and clarify checks for whether the IONOS integration is enabled and properly configured. These methods are now used throughout the codebase to ensure that actions are only performed when integration is fully set up. [1] [2]
  • Updated IonosMailConfigService to use the new IonosConfigService::isIonosIntegrationEnabled() method, ensuring that IONOS mail configuration options are only shown when the integration is correctly configured. [1] [2]

User Deletion Handling

  • Enhanced UserDeletedListener to attempt deletion of the user's IONOS mailbox via the API if the integration is enabled, logging success or failure, and ensuring Nextcloud mail accounts are still removed even if the IONOS deletion fails. [1] [2] [3]
  • Implemented a new deleteEmailAccount method in IonosMailService to handle mailbox deletion via the IONOS API, including proper error handling and logging.

API Client Refactoring

  • Renamed newEventAPIApi to newMailConfigurationAPIApi for clarity and updated all usages and tests accordingly. Added a new createApiInstance helper in IonosMailService to centralize API client instantiation. [1] [2] [3] [4] [5] [6] [7] [8]

Error Handling and Consistency

  • Standardized error handling in IonosMailService by using HTTP status code constants, updating exception handling, and using the correct error model classes from the IONOS API client. [1] [2] [3] [4]

Testing

  • Added unit tests for the new configuration logic in IonosConfigService, covering all cases for enabling/disabling the feature and handling missing configuration.

Dependency Update

@printminion-co printminion-co force-pushed the mk/dev/implement_ionosmail_deletion branch 4 times, most recently from 7c03137 to 7dbbd0c Compare November 10, 2025 16:41
@printminion-co printminion-co force-pushed the mk/dev/implement_ionosmail_deletion branch from 7dbbd0c to eec8415 Compare November 28, 2025 14:27
@printminion-co printminion-co force-pushed the mk/dev/implement_ionosmail_deletion branch 4 times, most recently from 9728b08 to 1f810b4 Compare November 28, 2025 17:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the IONOS Mail API client reference to version 2.0.0-20251110130214 and implements associated changes to handle the updated API, including renaming classes and methods to align with the new client version, and adding functionality to delete IONOS email accounts when users are removed.

  • Updates IONOS Mail API client reference from 2.0.0-20251031093901 to 2.0.0-20251110130214
  • Renames ErrorMessage to MailAddonErrorMessage throughout the codebase
  • Renames API method from newEventAPIApi to newMailConfigurationAPIApi
  • Adds IONOS mailbox deletion capability in UserDeletedListener

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
composer.json Updates the IONOS Mail API client git reference version
lib/Service/IONOS/ApiMailConfigClientService.php Renames method from newEventAPIApi to newMailConfigurationAPIApi
lib/Service/IONOS/IonosConfigService.php Adds methods to check mail config and IONOS integration status
lib/Service/IONOS/IonosMailConfigService.php Refactors to use IonosConfigService instead of directly accessing IConfig
lib/Service/IONOS/IonosMailService.php Updates to use MailAddonErrorMessage, adds HTTP constants, implements deleteEmailAccount method and createApiInstance helper
lib/Listener/UserDeletedListener.php Adds IONOS mailbox deletion when users are deleted
tests/Unit/Service/IONOS/ApiMailConfigClientServiceTest.php Updates test method calls to use renamed API method
tests/Unit/Service/IONOS/IonosConfigServiceTest.php Adds tests for new configuration checking methods
tests/Unit/Service/IONOS/IonosMailConfigServiceTest.php Updates tests to use IonosConfigService mock
tests/Unit/Service/IONOS/IonosMailServiceTest.php Updates all tests to use renamed classes and methods, adds comprehensive tests for new delete functionality
tests/Unit/Listener/UserDeletedListenerTest.php New test file providing comprehensive coverage for user deletion scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@printminion-co printminion-co changed the title IONOS(ionos-mail): update IONOS Mail API client reference to 2.0.0-20… Add ionos mail deletion on user account deletion Nov 28, 2025
…arity

Updated the method name from `newEventAPIApi` to `newMailConfigurationAPIApi` to better reflect its purpose in creating a new MailConfiguration API instance.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
@printminion-co printminion-co force-pushed the mk/dev/implement_ionosmail_deletion branch from 1f810b4 to dccbc8d Compare November 28, 2025 17:57
@printminion-co printminion-co changed the title Add ionos mail deletion on user account deletion add support for deleting IONOS mailboxes when a user is deleted, Nov 28, 2025
@printminion-co printminion-co changed the title add support for deleting IONOS mailboxes when a user is deleted, add support for deleting IONOS mailboxes when a user is deleted Nov 28, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

printminion-co added a commit that referenced this pull request Nov 28, 2025
- Add IONOS mailbox deletion support to AccountService
- When a mail account is deleted, check if it's an IONOS account by comparing email domain
- Automatically delete the IONOS mailbox via IonosMailService.tryDeleteEmailAccount()
- Graceful error handling ensures Nextcloud account deletion proceeds even if IONOS deletion fails
- Add comprehensive unit tests for IONOS account deletion scenarios
- Complements existing user deletion functionality from PR #17

This ensures IONOS mailboxes are properly cleaned up when users delete their mail accounts,
not just when the entire user is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
Added comprehensive unit tests for the UserDeletedListener to ensure proper handling of user deletion events, including scenarios with no accounts, single and multiple accounts, client exceptions, and partial failures. This enhances test coverage and reliability of the mail account deletion process.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
…deletion process

Improves code clarity by storing user ID in a variable before use in account deletion.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
… mail configuration checks

This change encapsulates the logic for checking if the IONOS mail configuration feature is enabled within a dedicated service, improving code organization and readability. The existing mail configuration checks in IonosMailConfigService have been refactored to utilize this new service.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
…integration checks

- Added isIonosIntegrationEnabled method to verify full integration configuration.
- Updated isMailConfigAvailable method to utilize the new integration check.
- Enhanced unit tests to cover new integration validation scenarios.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
@printminion-co printminion-co force-pushed the mk/dev/implement_ionosmail_deletion branch from dccbc8d to 562514c Compare December 4, 2025 09:26
…n user deletion

Add functionality to delete the IONOS mailbox when a user is deleted,
if the IONOS integration is enabled. This enhances the user deletion
process by ensuring associated email accounts are also removed,
improving data management and compliance.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
@printminion-co printminion-co force-pushed the mk/dev/implement_ionosmail_deletion branch from 562514c to 3071fa3 Compare December 4, 2025 09:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

printminion-co added a commit that referenced this pull request Dec 4, 2025
- Add IONOS mailbox deletion support to AccountService
- When a mail account is deleted, check if it's an IONOS account by comparing email domain
- Automatically delete the IONOS mailbox via IonosMailService.tryDeleteEmailAccount()
- Graceful error handling ensures Nextcloud account deletion proceeds even if IONOS deletion fails
- Add comprehensive unit tests for IONOS account deletion scenarios
- Complements existing user deletion functionality from PR #17

This ensures IONOS mailboxes are properly cleaned up when users delete their mail accounts,
not just when the entire user is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
printminion-co added a commit that referenced this pull request Dec 4, 2025
- Add IONOS mailbox deletion support to AccountService
- When a mail account is deleted, check if it's an IONOS account by comparing email domain
- Automatically delete the IONOS mailbox via IonosMailService.tryDeleteEmailAccount()
- Graceful error handling ensures Nextcloud account deletion proceeds even if IONOS deletion fails
- Add comprehensive unit tests for IONOS account deletion scenarios
- Complements existing user deletion functionality from PR #17

This ensures IONOS mailboxes are properly cleaned up when users delete their mail accounts,
not just when the entire user is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
printminion-co added a commit that referenced this pull request Dec 4, 2025
- Add IONOS mailbox deletion support to AccountService
- When a mail account is deleted, check if it's an IONOS account by comparing email domain
- Automatically delete the IONOS mailbox via IonosMailService.tryDeleteEmailAccount()
- Graceful error handling ensures Nextcloud account deletion proceeds even if IONOS deletion fails
- Add comprehensive unit tests for IONOS account deletion scenarios
- Complements existing user deletion functionality from PR #17

This ensures IONOS mailboxes are properly cleaned up when users delete their mail accounts,
not just when the entire user is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
printminion-co added a commit that referenced this pull request Dec 4, 2025
Add automatic IONOS mailbox deletion when users delete their mail accounts in Nextcloud.

- Introduce IonosAccountDeletionService to handle mailbox cleanup logic
- Integrate deletion hook into AccountService.delete() and deleteByAccountId()
- Verify account ownership by comparing email domain and provisioned email
- Add graceful error handling to ensure NC account deletion proceeds even if IONOS deletion fails
- Implement comprehensive unit tests for all deletion scenarios
- Add IonosMailService.getIonosEmailForUser() to retrieve provisioned email addresses

This complements existing user deletion functionality from PR #17 by ensuring IONOS mailboxes
are properly cleaned up when users delete their mail accounts, not just when the entire user
is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
@printminion-co printminion-co merged commit 4f6bc6e into ionos-dev Dec 4, 2025
22 of 27 checks passed
@printminion-co printminion-co deleted the mk/dev/implement_ionosmail_deletion branch December 4, 2025 12:16
printminion-co added a commit that referenced this pull request Dec 4, 2025
Add automatic IONOS mailbox deletion when users delete their mail accounts in Nextcloud.

- Introduce IonosAccountDeletionService to handle mailbox cleanup logic
- Integrate deletion hook into AccountService.delete() and deleteByAccountId()
- Verify account ownership by comparing email domain and provisioned email
- Add graceful error handling to ensure NC account deletion proceeds even if IONOS deletion fails
- Implement comprehensive unit tests for all deletion scenarios
- Add IonosMailService.getIonosEmailForUser() to retrieve provisioned email addresses

This complements existing user deletion functionality from PR #17 by ensuring IONOS mailboxes
are properly cleaned up when users delete their mail accounts, not just when the entire user
is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
printminion-co added a commit that referenced this pull request Dec 4, 2025
Add automatic IONOS mailbox deletion when users delete their mail accounts in Nextcloud.

- Introduce IonosAccountDeletionService to handle mailbox cleanup logic
- Integrate deletion hook into AccountService.delete() and deleteByAccountId()
- Verify account ownership by comparing email domain and provisioned email
- Add graceful error handling to ensure NC account deletion proceeds even if IONOS deletion fails
- Implement comprehensive unit tests for all deletion scenarios
- Add IonosMailService.getIonosEmailForUser() to retrieve provisioned email addresses

This complements existing user deletion functionality from PR #17 by ensuring IONOS mailboxes
are properly cleaned up when users delete their mail accounts, not just when the entire user
is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
printminion-co added a commit that referenced this pull request Dec 4, 2025
Add automatic IONOS mailbox deletion when users delete their mail accounts in Nextcloud.

- Introduce IonosAccountDeletionService to handle mailbox cleanup logic
- Integrate deletion hook into AccountService.delete() and deleteByAccountId()
- Verify account ownership by comparing email domain and provisioned email
- Add graceful error handling to ensure NC account deletion proceeds even if IONOS deletion fails
- Implement comprehensive unit tests for all deletion scenarios
- Add IonosMailService.getIonosEmailForUser() to retrieve provisioned email addresses

This complements existing user deletion functionality from PR #17 by ensuring IONOS mailboxes
are properly cleaned up when users delete their mail accounts, not just when the entire user
is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
printminion-co added a commit that referenced this pull request Dec 4, 2025
Add automatic IONOS mailbox deletion when users delete their mail accounts in Nextcloud.

- Introduce IonosAccountDeletionService to handle mailbox cleanup logic
- Integrate deletion hook into AccountService.delete() and deleteByAccountId()
- Verify account ownership by comparing email domain and provisioned email
- Add graceful error handling to ensure NC account deletion proceeds even if IONOS deletion fails
- Implement comprehensive unit tests for all deletion scenarios
- Add IonosMailService.getIonosEmailForUser() to retrieve provisioned email addresses

This complements existing user deletion functionality from PR #17 by ensuring IONOS mailboxes
are properly cleaned up when users delete their mail accounts, not just when the entire user
is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
printminion-co added a commit that referenced this pull request Dec 4, 2025
Add automatic IONOS mailbox deletion when users delete their mail accounts in Nextcloud.

- Introduce IonosAccountDeletionService to handle mailbox cleanup logic
- Integrate deletion hook into AccountService.delete() and deleteByAccountId()
- Verify account ownership by comparing email domain and provisioned email
- Add graceful error handling to ensure NC account deletion proceeds even if IONOS deletion fails
- Implement comprehensive unit tests for all deletion scenarios
- Add IonosMailService.getIonosEmailForUser() to retrieve provisioned email addresses

This complements existing user deletion functionality from PR #17 by ensuring IONOS mailboxes
are properly cleaned up when users delete their mail accounts, not just when the entire user
is deleted from the system.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
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