Skip to content

Commit

Permalink
Merge pull request #25 from freescout-helpdesk/analysis-zOVYOP
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
freescout-helpdesk authored Aug 4, 2018
2 parents 703be82 + 9c8866f commit 9c1bf93
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions app/Console/Commands/FetchEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function fetch($mailbox)
$this->line('['.date('Y-m-d H:i:s').'] Fetched: '.count($messages));

$message_index = 1;

try {
// We have to sort messages manually, as they can be in non-chronological order
$messages = $this->sortMessage($messages);
Expand Down Expand Up @@ -184,8 +185,9 @@ public function fetch($mailbox)
$this->logError('Error occured processing message');
}
}
} catch(\Exception $e) {
} catch (\Exception $e) {
$message->setFlag(['Seen']);

throw $e;
}
}
Expand All @@ -207,7 +209,7 @@ public function logError($message)
])
->useLog(\App\ActivityLog::NAME_EMAILS_FETCHING)
->log(\App\ActivityLog::DESCRIPTION_EMAILS_FETCHING_ERROR);
} catch(\Exception $e) {
} catch (\Exception $e) {
// Do nothing
}
}
Expand Down Expand Up @@ -325,10 +327,11 @@ public function saveAttachments($email_attachments, $thread_id)
*/
public function separateReply($body, $is_html, $is_reply)
{
$cmp_reply_length_desc = function($a, $b) {
$cmp_reply_length_desc = function ($a, $b) {
if (mb_strlen($a) == mb_strlen($b)) {
return 0;
}

return (mb_strlen($a) < mb_strlen($b)) ? -1 : 1;
};

Expand Down Expand Up @@ -365,6 +368,7 @@ public function separateReply($body, $is_html, $is_reply)
}
if (count($reply_bodies)) {
usort($reply_bodies, $cmp_reply_length_desc);

return $reply_bodies[0];
}
}
Expand Down Expand Up @@ -414,15 +418,17 @@ public function formatEmailList($obj_list)

/**
* We have to sort messages manually, as they can be in non-chronological order.
*
* @param Collection $messages
*
* @param Collection $messages
*
* @return Collection
*/
public function sortMessage($messages)
{
$messages = $messages->sortBy(function ($message, $key) {
return $message->getDate()->timestamp;
});

return $messages;
}
}
2 changes: 1 addition & 1 deletion app/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public function getFirstName($email_if_empty = false)

/**
* Get first part of the email.
*
*
* @return string
*/
public function getNameFromEmail()
Expand Down
2 changes: 1 addition & 1 deletion app/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function sanitizeEmail($email)
// Email validation is not recommended:
// http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address/201378#201378
// So we just check for @
if (!preg_match("/@/", $email)) {
if (!preg_match('/@/', $email)) {
return false;
}
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
Expand Down
2 changes: 1 addition & 1 deletion app/Mail/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Mail
public static $alternative_reply_separators = [
self::REPLY_SEPARATOR_HTML,
'<div class="gmail_quote">',
'<blockquote'
'<blockquote',
];

/**
Expand Down

0 comments on commit 9c1bf93

Please sign in to comment.