feat(UserMigration): Overwork migration to include all settings (trusted senders)#12782
feat(UserMigration): Overwork migration to include all settings (trusted senders)#12782DerDreschner wants to merge 2 commits intofeat/user-migration-appsettingsfrom
Conversation
23fa5cd to
8118180
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Extends the mail user-migration flow to include “trusted senders” settings by exporting/importing them and clearing existing entries before import.
Changes:
- Add
TrustedSendersMigrationServiceto export/import/remove trusted senders during migration. - Wire the service into
MailAccountMigratorexport/import/delete flows. - Add PHPUnit unit tests covering trusted senders export/import scenarios and invalid inputs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
lib/UserMigration/Service/TrustedSendersMigrationService.php |
Implements export/import/removal of trusted senders and validates import structure. |
lib/UserMigration/MailAccountMigrator.php |
Integrates trusted senders migration into the overall mail migrator lifecycle. |
tests/Unit/UserMigration/Service/TrustedSendersMigrationServiceTest.php |
Adds unit tests for trusted senders export/import behavior and error cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $trustedSenderArrayIsValid = is_array($trustedSender); | ||
| $emailIsValid = array_key_exists('email', $trustedSender) && is_string($trustedSender['email']); | ||
| $typeIsValid = array_key_exists('type', $trustedSender) && is_string($trustedSender['type']); | ||
|
|
||
| if (!$trustedSenderArrayIsValid || !$emailIsValid || !$typeIsValid) { |
There was a problem hiding this comment.
The new validation logic has multiple branches that aren’t covered by the current unit tests (e.g., an entry that is not an array, missing email/type, or non-string values). Add unit tests that assert UserMigrationException is thrown for these specific malformed structures (and that non-array items don’t cause a TypeError once fixed).
| $trustedSenderArrayIsValid = is_array($trustedSender); | |
| $emailIsValid = array_key_exists('email', $trustedSender) && is_string($trustedSender['email']); | |
| $typeIsValid = array_key_exists('type', $trustedSender) && is_string($trustedSender['type']); | |
| if (!$trustedSenderArrayIsValid || !$emailIsValid || !$typeIsValid) { | |
| if (!is_array($trustedSender)) { | |
| throw new UserMigrationException('Invalid trusted sender entry'); | |
| } | |
| $emailIsValid = array_key_exists('email', $trustedSender) && is_string($trustedSender['email']); | |
| $typeIsValid = array_key_exists('type', $trustedSender) && is_string($trustedSender['type']); | |
| if (!$emailIsValid || !$typeIsValid) { |
a67fc2b to
650d9b1
Compare
451cab5 to
d87ab82
Compare
00fcc54 to
8eb6d2c
Compare
8eb6d2c to
d06d535
Compare
…c changes) Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
…ted senders) Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
d87ab82 to
dbd5edd
Compare
| private function validateTrustedSenders(mixed $trustedSenders): void { | ||
| $trustedSendersArrayIsValid = is_array($trustedSenders) && array_is_list($trustedSenders); | ||
| if (!$trustedSendersArrayIsValid) { | ||
| throw new UserMigrationException('Invalid trusted senders export structure'); |
There was a problem hiding this comment.
If throwing an exception in this method aborts the import, I would suggest to ignore the exception, catch it, or just go ahead. While losing all trusted senders might be annoying, not being able to complete the import might be even more annoying.
This PR belongs to a series of PRs that will enhance the user migration to include all settings.
Included changes in this PR:
I didn't include any unit tests for the removal code as that only calls another function.
Please ignore the failed CI run regarding the unconventional commit message. That happens as I tag another feature branch for better overview here.
Refs #12001