Bugfix: ImapContactsSuggestions error on empty $aUids

This commit is contained in:
the-djmaze 2022-05-28 23:38:41 +02:00
parent 4c752f9a15
commit 48a954e077

View file

@ -29,11 +29,13 @@ class ImapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
);
$aResult = [];
foreach ($oImapClient->Fetch(['BODY.PEEK[HEADER.FIELDS (FROM)]'], \implode(',', $aUids), true) as $oFetchResponse) {
$oHeaders = new \MailSo\Mime\HeaderCollection($oFetchResponse->GetHeaderFieldsValue());
$oFrom = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, true);
foreach ($oFrom as $oMail) {
$aResult[] = [$oMail->GetEmail(), $oMail->GetDisplayName()];
if ($aUids) {
foreach ($oImapClient->Fetch(['BODY.PEEK[HEADER.FIELDS (FROM)]'], \implode(',', $aUids), true) as $oFetchResponse) {
$oHeaders = new \MailSo\Mime\HeaderCollection($oFetchResponse->GetHeaderFieldsValue());
$oFrom = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, true);
foreach ($oFrom as $oMail) {
$aResult[] = [$oMail->GetEmail(), $oMail->GetDisplayName()];
}
}
}