Skip to content

Commit

Permalink
Improve fetching email in Show Original window - closes #3658
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Jan 5, 2024
1 parent c55d94d commit b2dae09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/Misc/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,11 @@ public static function fetchMessage($mailbox, $message_id, $message_date = null)
foreach ($imap_folders as $folder_name) {
try {
$folder = self::getImapFolder($client, $folder_name);

if (!$folder) {
\Log::error('('.$mailbox->name.') Show Original - folder not found: '.$folder_name);
continue;
}
// Message-ID: <[email protected]>
$query = $folder->query()
->text('<'.$message_id.'>')
Expand Down Expand Up @@ -763,7 +768,7 @@ public static function fetchMessage($mailbox, $message_id, $message_date = null)
$query = $folder->query()->text('<'.$message_id.'>')->leaveUnread()->limit(1)->setCharset(null);
if ($message_date) {
$query->since($message_date->subDays(7));
$query->before($message_date->addDays(7));
$query->before($message_date->addDays(14));
}
$messages = $query->get();
$no_charset = true;
Expand Down
6 changes: 6 additions & 0 deletions app/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,12 @@ public function fetchBody()
{
$message = \MailHelper::fetchMessage($this->conversation->mailbox, $this->message_id, $this->getMailDate());

// Try without limiting by date.
// https://github.com/freescout-helpdesk/freescout/issues/3658
if (!$message) {
$message = \MailHelper::fetchMessage($this->conversation->mailbox, $this->message_id);
}

if (!$message) {
return '';
}
Expand Down

0 comments on commit b2dae09

Please sign in to comment.