diff --git a/lib/IMAP/PreviewEnhancer.php b/lib/IMAP/PreviewEnhancer.php index 978960973c..f115307d1a 100644 --- a/lib/IMAP/PreviewEnhancer.php +++ b/lib/IMAP/PreviewEnhancer.php @@ -65,7 +65,7 @@ public function process(Account $account, Mailbox $mailbox, array $messages): ar if ($message->getStructureAnalyzed()) { // Try fetching the avatar if it's not set $from = $message->getFrom()->first() ; - if ($message->getAvatar() === null && $from !== null && $this->userId !== null) { + if ($message->getAvatar() === null && $from !== null && $from->getEmail() !== null && $this->userId !== null) { $avatar = $this->avatarService->getAvatar($from->getEmail(), $this->userId); $message->setAvatar($avatar); } @@ -114,10 +114,9 @@ public function process(Account $account, Mailbox $mailbox, array $messages): ar $message->setMentionsMe($structureData->getMentionsMe()); $from = $message->getFrom()->first() ; - if ($message->getAvatar() === null && $from !== null && $this->userId !== null) { - $avatar = $this->avatarService->getAvatar($message->getFrom()->first()->getEmail(), $this->userId); + if ($message->getAvatar() === null && $from !== null && $from->getEmail() !== null && $this->userId !== null) { + $avatar = $this->avatarService->getAvatar($from->getEmail(), $this->userId); $message->setAvatar($avatar); - } return $message;