|
6 | 6 | use DirectoryTree\ImapEngine\Collections\ResponseCollection; |
7 | 7 | use DirectoryTree\ImapEngine\Connection\ConnectionInterface; |
8 | 8 | use DirectoryTree\ImapEngine\Connection\ImapQueryBuilder; |
| 9 | +use DirectoryTree\ImapEngine\Connection\Responses\Data\ListData; |
9 | 10 | use DirectoryTree\ImapEngine\Connection\Responses\UntaggedResponse; |
10 | 11 | use DirectoryTree\ImapEngine\Connection\Tokens\Token; |
11 | 12 | use DirectoryTree\ImapEngine\Enums\ImapFetchIdentifier; |
12 | 13 | use DirectoryTree\ImapEngine\Enums\ImapFlag; |
13 | 14 | use DirectoryTree\ImapEngine\Exceptions\ImapCommandException; |
| 15 | +use DirectoryTree\ImapEngine\Exceptions\RuntimeException; |
14 | 16 | use DirectoryTree\ImapEngine\Pagination\LengthAwarePaginator; |
15 | 17 | use DirectoryTree\ImapEngine\Support\Str; |
16 | 18 | use Illuminate\Support\Collection; |
@@ -189,7 +191,8 @@ public function findOrFail(int $id, ImapFetchIdentifier $identifier = ImapFetchI |
189 | 191 | public function find(int $id, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid): ?MessageInterface |
190 | 192 | { |
191 | 193 | /** @var UntaggedResponse $response */ |
192 | | - if (! $response = $this->id($id, $identifier)->first()) { |
| 194 | + $response = $this->id($id, $identifier)->first(); |
| 195 | + if (! $response) { |
193 | 196 | return null; |
194 | 197 | } |
195 | 198 |
|
@@ -294,6 +297,10 @@ protected function fetch(Collection $messages): array |
294 | 297 | return $this->connection()->fetch($fetch, $uids->all())->mapWithKeys(function (UntaggedResponse $response) { |
295 | 298 | $data = $response->tokenAt(3); |
296 | 299 |
|
| 300 | + if (!$data instanceof ListData) { |
| 301 | + throw new RuntimeException("Invalid data type at index 3"); |
| 302 | + } |
| 303 | + |
297 | 304 | $uid = $data->lookup('UID')->value; |
298 | 305 |
|
299 | 306 | return [ |
|
0 commit comments