Skip to content

Commit

Permalink
fixup! perf: reduce number of avatar requests
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Dec 13, 2024
1 parent 3a3867b commit d4f5514
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/IMAP/PreviewEnhancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check warning on line 70 in lib/IMAP/PreviewEnhancer.php

View check run for this annotation

Codecov / codecov/patch

lib/IMAP/PreviewEnhancer.php#L67-L70

Added lines #L67 - L70 were not covered by tests
}
Expand Down Expand Up @@ -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);

Check warning on line 119 in lib/IMAP/PreviewEnhancer.php

View check run for this annotation

Codecov / codecov/patch

lib/IMAP/PreviewEnhancer.php#L116-L119

Added lines #L116 - L119 were not covered by tests

}

return $message;
Expand Down

0 comments on commit d4f5514

Please sign in to comment.