Skip to content

Commit

Permalink
Merge branch 'master' of github.com:freescout-helpdesk/freescout into…
Browse files Browse the repository at this point in the history
… dist
  • Loading branch information
freescout-help-desk committed Jan 6, 2024
2 parents 7d035f5 + b2dae09 commit 885001e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/FetchEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public function processMessage($message, $message_id, $mailbox, $mailboxes, $ext
$body = $message->getTextBody() ?? '';
$body = htmlspecialchars($body);
}
$body = $this->separateReply($body, $is_html, $is_reply, !$message_from_customer, ($message_from_customer ? $prev_thread->getMessageId($mailbox) : ''));
$body = $this->separateReply($body, $is_html, $is_reply, !$message_from_customer, (($message_from_customer && $prev_thread) ? $prev_thread->getMessageId($mailbox) : ''));

// We have to fetch absolutely all emails, even with empty body.
// if (!$body) {
Expand Down
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 885001e

Please sign in to comment.