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 May 24, 2022
2 parents c1a2b81 + 3904e6d commit 403a160
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 18 deletions.
17 changes: 9 additions & 8 deletions app/Console/Commands/FetchEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,17 @@ public function fetch($mailbox)

// Get unseen messages for a period
$last_error = '';
$messages = collect([]);

try {
$messages = $folder->query()->since(now()->subDays($this->option('days')))->leaveUnread();
$messages_query = $folder->query()->since(now()->subDays($this->option('days')))->leaveUnread();
if ($unseen) {
$messages->unseen();
$messages_query->unseen();
}
if ($no_charset) {
$messages->setCharset(null);
$messages_query->setCharset(null);
}
$messages = $messages->get();
$messages = $messages_query->get();

if (method_exists($client, 'getLastError')) {
$last_error = $client->getLastError();
Expand All @@ -188,11 +190,11 @@ public function fetch($mailbox)
$errors_count = count($client->getErrors());
// Solution for MS mailboxes.
// https://github.com/freescout-helpdesk/freescout/issues/176
$messages = $folder->query()->since(now()->subDays($this->option('days')))->leaveUnread()->setCharset(null);
$messages_query = $folder->query()->since(now()->subDays($this->option('days')))->leaveUnread()->setCharset(null);
if ($unseen) {
$messages->unseen();
$messages_query->unseen();
}
$messages = $messages->get();
$messages = $messages_query->get();

$no_charset = true;
if (count($client->getErrors()) > $errors_count) {
Expand All @@ -209,7 +211,6 @@ public function fetch($mailbox)
} else {
$this->error('['.date('Y-m-d H:i:s').'] '.$last_error);
$this->logError('Folder: '.$folder->name.'; Error: '.$last_error);
$messages = collect([]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ public function getPhotoUrl($default_if_empty = true)
return '';
}
} else {
return asset('/img/default-avatar.png');
return \Eventy::filter('customer.default_avatar', '/img/default-avatar.png', $this);
}
}

Expand Down
7 changes: 6 additions & 1 deletion app/Http/Controllers/ModulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function modules(Request $request)
\Module::clearCache();
$modules = \Module::all();
foreach ($modules as $module) {
$installed_modules[] = [
$module_data = [
'alias' => $module->getAlias(),
'name' => $module->getName(),
'description' => $module->getDescription(),
Expand All @@ -74,6 +74,8 @@ public function modules(Request $request)
// Determined later
'new_version' => '',
];
$module_data = \App\Module::formatModuleData($module_data);
$installed_modules[] = $module_data;
}

// No need, as we update modules list on each page load
Expand All @@ -85,6 +87,9 @@ public function modules(Request $request)
// Prepare directory modules
if (is_array($modules_directory)) {
foreach ($modules_directory as $i_dir => $dir_module) {

$modules_directory[$i_dir] = \App\Module::formatModuleData($dir_module);

// Remove modules without aliases
if (empty($dir_module['alias'])) {
unset($modules_directory[$i_dir]);
Expand Down
7 changes: 6 additions & 1 deletion app/Jobs/SendReplyToCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,13 @@ public function handle()
$part1['contents.data'] = $reply_mail->render();

try {
// getFolder does not work if sent folder has spaces.
$folder = $client->getFolder($imap_sent_folder);
$folder->appendMessage(imap_mail_compose($envelope, [$part1]), '\Seen', now()->format('d-M-Y H:i:s O'));
if ($folder) {
$folder->appendMessage(imap_mail_compose($envelope, [$part1]), '\Seen', now()->format('d-M-Y H:i:s O'));
} else {
\Log::error('Could not save outgoing reply to the IMAP folder (make sure IMAP folder does not have spaces - folders with spaces do not work): '.$imap_sent_folder);
}
} catch (\Exception $e) {
// Just log error and continue.
\Helper::logException($e, 'Could not save outgoing reply to the IMAP folder, IMAP folder not found: '.$imap_sent_folder.' - ');
Expand Down
14 changes: 13 additions & 1 deletion app/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ public static function getMissingModules($required_modules, $modules = [])

public static function formatName($name)
{
return preg_replace("/ Module$/", '', $name);
return preg_replace("/ Module($|.*\[.*\]$)/", '$1', $name);
}

public static function formatModuleData($module_data)
{
// Add (Third-Party).
if (\App\Module::isOfficial($module_data['authorUrl'])
&& $module_data['author'] != 'FreeScout'
&& mb_substr(trim($module_data['name']), -1) != ']'
) {
$module_data['name'] = $module_data['name'].' ['.__('Third-Party').']';
}
return $module_data;
}
}
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
| or any other location as required by the application or its packages.
*/

'version' => '1.8.15',
'version' => '1.8.16',

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</a>
<ul class="dropdown-menu dm-scrollable">
@foreach ($mailboxes as $mailbox_item)
<li @if ($mailbox_item->id == app('request')->id)class="active"@endif><a href="{{ \Eventy::filter('mailbox.url', route('mailboxes.view', ['id' => $mailbox_item->id]), $mailbox_item) }}">{{ $mailbox_item->name }}</a></li>
<li @if ($mailbox_item->id == app('request')->id)class="active"@endif><a href="{{ \Eventy::filter('mailbox.url', route('mailboxes.view', ['id' => $mailbox_item->id]), $mailbox_item) }}">@action('mailbox.before_name', $mailbox_item){{ $mailbox_item->name }}</a></li>
@endforeach
</ul>
</li>
Expand Down
5 changes: 3 additions & 2 deletions resources/views/mailboxes/sidebar_menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
@php
$menu_mailboxes = auth()->user()->mailboxesCanView();
@endphp
@action('mailbox.before_name', $mailbox)
<span class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" v-pre>
{{ $mailbox->name }} @if (count($menu_mailboxes))<span class="caret"></span>@endif
</span>
@if (count($menu_mailboxes))
<ul class="dropdown-menu dm-scrollable">
@foreach ($menu_mailboxes as $mailbox_item)
<li @if ($mailbox_item->id == $mailbox->id)class="active"@endif><a href="{{ route(Eventy::filter('mailboxes.menu_current_route', Route::currentRouteName()), ['id'=>$mailbox_item->id]) }}">{{ $mailbox_item->name }}</a></li>
<li @if ($mailbox_item->id == $mailbox->id)class="active"@endif><a href="{{ route(Eventy::filter('mailboxes.menu_current_route', Route::currentRouteName()), ['id'=>$mailbox_item->id]) }}">@action('mailbox.before_name', $mailbox_item){{ $mailbox_item->name }}</a></li>
@endforeach
</ul>
@endif
Expand All @@ -17,4 +18,4 @@
<ul class="sidebar-menu">
@include("mailboxes/settings_menu")
</ul>
<a href="{{ route('mailboxes.view', ['id' => $mailbox->id]) }}" class="btn btn-bordered btn-sidebar btn-rounded" data-toggle="tooltip" title="{{ __("Open Mailbox") }}"><i class="glyphicon glyphicon-arrow-right"></i></a>
<a href="{{ route('mailboxes.view', ['id' => $mailbox->id]) }}" class="btn btn-bordered btn-sidebar btn-rounded" data-toggle="tooltip" title="{{ __("Open Mailbox") }}"><i class="glyphicon glyphicon-arrow-right"></i></a>
3 changes: 2 additions & 1 deletion resources/views/mailboxes/sidebar_menu_view.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="dropdown sidebar-title sidebar-title-extra">
<span class="sidebar-title-extra-value active-count">{{ $folder->getTypeName() }} ({{ $folder->active_count }})</span>
@action('mailbox.before_name', $mailbox)
<span class="sidebar-title-real mailbox-name">@include('mailboxes/partials/mute_icon', ['mailbox' => $mailbox]){{ $mailbox->name }}</span>
<span class="sidebar-title-email">{{ $mailbox->email }}</span>
</div>
Expand All @@ -22,4 +23,4 @@
<a class="btn btn-trans" href="{{ route('conversations.create', ['mailbox_id' => $mailbox->id]) }}" aria-label="{{ __("New Conversation") }}" data-toggle="tooltip" title="{{ __("New Conversation") }}" role="button"><i class="glyphicon glyphicon-envelope"></i></a>
</div>
@endif
@action('mailbox.after_sidebar_buttons')
@action('mailbox.after_sidebar_buttons')
4 changes: 3 additions & 1 deletion resources/views/mailboxes/update.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
<div class="row-container form-container">
<div class="row">
<div class="col-xs-12">
<form class="form-horizontal margin-top" method="POST" action="">
<form class="form-horizontal margin-top" method="POST" action="" enctype="multipart/form-data">
{{ csrf_field() }}

@action('mailbox.update.before_name', $mailbox)

<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="col-sm-2 control-label">{{ __('Mailbox Name') }}</label>
Expand Down
1 change: 1 addition & 0 deletions resources/views/secure/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@foreach ($mailboxes as $mailbox)
<div class="dash-card @if (!$mailbox->isActive()) dash-card-inactive @endif">
<div class="dash-card-content">
@action('mailbox.before_name', $mailbox)
<h3 class="text-wrap-break "><a href="{{ $mailbox->url() }}" class="mailbox-name">@include('mailboxes/partials/mute_icon', ['mailbox' => $mailbox]){{ $mailbox->name }}</a></h3>
<div class="dash-card-link text-truncate">
<a href="{{ $mailbox->url() }}" class="text-truncate help-link">{{ $mailbox->email }}</a>
Expand Down

0 comments on commit 403a160

Please sign in to comment.