-
Notifications
You must be signed in to change notification settings - Fork 0
Restrict email processing to INBOX only #97
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
base: main
Are you sure you want to change the base?
Conversation
- Added check in processMailbox() to only process emails from INBOX folder - Updated tests to verify non-INBOX folders are not processed - Removed obsolete tests that expected emails to move between non-INBOX folders - All 8 unit tests pass (1 integration test requires database) Co-authored-by: HNygard <168380+HNygard@users.noreply.github.com>
|
You have run out of free Bugbot PR reviews for this billing cycle. This will reset on January 27. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
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.
Pull request overview
This PR restricts email processing to only the INBOX folder, preventing unintended reorganization of emails in non-INBOX folders like Sent and thread folders. Previously, emails were being moved between these folders, causing already-filed messages to be reorganized unexpectedly.
Key Changes:
- Added early return guard in
ThreadEmailMover::processMailbox()that skips processing for any mailbox other than 'INBOX' - Replaced 3 parameterized tests expecting non-INBOX moves with a single test verifying no-op behavior for non-INBOX mailboxes
- Non-INBOX processing now returns empty results without fetching or moving any emails
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| organizer/src/class/ThreadEmailMover.php | Added early return check at the start of processMailbox() to skip any mailbox that isn't 'INBOX', returning empty unmatched list and maxed_out=false |
| organizer/src/tests/ThreadEmailMoverTest.php | Removed data provider and 3 parameterized tests for non-INBOX behavior; added single test testProcessNonInboxMailboxDoesNothing() verifying that no emails are fetched or moved from non-INBOX mailboxes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Only process emails from INBOX - never move emails from other folders | ||
| if ($mailbox !== 'INBOX') { | ||
| return array( | ||
| 'unmatched' => [], | ||
| 'maxed_out' => false, | ||
| ); | ||
| } |
Copilot
AI
Dec 30, 2025
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.
The strict equality check $mailbox !== 'INBOX' will prevent processing of any folder that isn't exactly 'INBOX'. This is the intended behavior based on the PR description.
However, this means functions like processSentFolder() in update-imap-functions.php that call processMailbox() with 'Sent' or 'INBOX.Sent' will now silently return empty results without any indication that they were skipped. Consider adding a debug log message here to make the skip explicit and easier to debug, for example:
$this->connection->logDebug("Skipping mailbox '$mailbox' - only INBOX is processed");
This would help operators understand the behavior when reviewing logs.
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.
@copilot apply changes based on this feedback
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.
Added debug logging in commit 5e6584e. The log message now reads: "Skipping mailbox '$mailbox' - only INBOX is processed"
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Addresses review feedback to make the skip behavior explicit in logs, helping operators understand when folders are being skipped. Co-authored-by: HNygard <168380+HNygard@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Task: Change logic so that we never move email out of a folder other than INBOX
✅ Completed
Changes Made
ThreadEmailMover.php:
processMailbox()method to only process emails when$mailbox === 'INBOX'ThreadEmailMoverTest.php:
testProcessNonInboxMailboxDoesNothing()Test Results
Impact Analysis
update-imap-functions.phpwill now effectively do nothing (as intended)Security
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.