Skip to content
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

add search method for messages with UID greater than X #201

Merged
merged 2 commits into from
Mar 7, 2022

Conversation

HelloSebastian
Copy link
Contributor

@HelloSebastian HelloSebastian commented Feb 20, 2022

maybe fixed #200

Hi @Webklex,

the getMessagesGreaterThanUid function searches for all messages that have a UID greater than or equal to the one passed. The found messages are initialized and returned as MessageCollection.

The proposed method is perhaps not the fastest, because each message is initialized individually. I took the foreach from the ImapProtocol::overview method and adapted it a bit.

I am also not sure if the Query class is the right place for the method. I didn't put the method in the WhereQuery class because it can't be linked to other conditions.

Example:

/** @var Folder $inbox */
$inbox = $client->getFolderByName("INBOX");

$messages = $inbox->query()->getMessagesGreaterThanUid(1600);

It is important to note that the returned MessageColletion may or may not contain the passed UID. Depending on whether the UID is present on the server.

What do you think about the solution, @Webklex?

The getMessagesGreaterThanUid function searches for all messages that have a UID greater than or equal to the one passed. The found messages are initialized and returned as MessageCollection.
@HelloSebastian HelloSebastian marked this pull request as ready for review February 20, 2022 14:38
@HelloSebastian
Copy link
Contributor Author

HelloSebastian commented Feb 20, 2022

I have improved the performance by using the populate() method instead of initializing each message individually. The structure is now similar to the get() method.

I have also renamed the getMessagesGreaterThanUid method to getByUidGreaterThanEqual. However, I am still unsure which name is better, or a completely different name would be better.

@HelloSebastian
Copy link
Contributor Author

Hi @Webklex,

I saw that you are planning to release a new version early next week.
#205 (comment)

Is there anything against merging the PR and making it available in the new release?

Do you agree with the naming of the method?

I look forward to hearing from you.

@Webklex Webklex merged commit af9cf90 into Webklex:master Mar 7, 2022
@HelloSebastian HelloSebastian deleted the issue-200 branch March 15, 2022 13:39
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.

Search for messages with UID greater than X
2 participants