Skip to content

Add exists() and doesntExist() to message queries - #216

Merged
stevebauman merged 1 commit into
masterfrom
feature/message-existence-checks
Nov 25, 2026
Merged

stevebauman merged 1 commit into
masterfrom
feature/message-existence-checks

Conversation

@stevebauman

Copy link
Copy Markdown
Member

Sometimes you only need to know whether a folder has any messages that match a query. For example, you might want to skip an inbox import when there are no unread messages.

exists() and doesntExist() use the current IMAP search filters and return a boolean without fetching message data.

if ($mailbox->inbox()->messages()->unseen()->doesntExist()) {
    return;
}

Custom implementations of MessageQueryInterface need to implement both methods.

@stevebauman
stevebauman merged commit 69bcaee into master Nov 25, 2026
13 checks passed
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.

1 participant