-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Added searching by UID #161
Conversation
@Webklex, should I improve anything? |
Hi @szymekjanaczek , Anyway many thanks for your pull request :) Best regards, |
Hi, @Webklex Sure, I can! Theory and docs[RFC 3501] - [2.3.1.1.] Unique Identifier (UID) Message Attribute TLDRMessage UID is a unique code assigned to each message. It's persistent, which means that when we have for example this situation in our mailbox...
... and we remove the message with UID = 2, the message which has UID = 3 stays the number three:
Disclaimer: UID is assigned separately per each folder. So when we move the message from one folder to another, it gets a new UID - the highest one free in a new folder. DescriptionLet's suppose we want to get specific messages from the Inbox. Before my PR we only search them by various criteria like TEXT, SUBJECT, etc. But it's still searching. So what when we've to get some different entities? Practical example:Let's suppose we want to connect IMAP message entities with e.g. notes from the database.
And let's assume, we want to get from IMAP all messages with the assigned note. // Let's mock an example database response from messages table.
$databaseMessages = [
['path' => 'INBOX', 'uid' => 1, 'note' => 'foo'],
['path' => 'INBOX', 'uid' => 5, 'note' => 'bar'],
['path' => 'INBOX', 'uid' => 7, 'note' => 'lorem'],
];
/** @var MessageCollection<Message> $messages */
$messages = $query->whereUidIn($uidList)->get();
/*
* Now we have a MessageCollection of Message entities.
* we can iterate through them, to perform any action or just return this list as a response.
*/
foreach ($messages as $message) {
$message->setFlag('Seen');
}
return $messages; I'm not sure, what do you mean here:
Could you explain it, please? To let me answer. |
Thanks, that's perfect! Never mind, by trying to answer it I answered my own question :D I was thinking if it is possible to search for all uids which contain a certain number like Anyway thanks for taking your time and your contribution. Best regards, |
That's great ;p No, I don't know anything about this possibility in pure IMAP. /** @var MessageCollection<Message> $messages */
$messages = $query->whereUid('1:3')->get();
$messages = $query->whereUid('1,3,5')->get();
$messages = $query->whereUid(1)->get(); |
Can I do anything else to prepare this feature for release? |
Hi @szymekjanaczek , Best regards, |
Great, thanks |
Thanks, you too :) |
Hi @Webklex,
I just added the possibility of searching for messages by their UID codes. Additionally, created some helper methods to simplify searching.