diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 7744d11e0..f2f9ae8e3 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -112,7 +112,7 @@ protected function schedule(Schedule $schedule) if (count($running_commands) > 1) { // Stop all queue:work processes. // queue:work command is stopped by settings a cache key - \Cache::forever('illuminate:queue:restart', Carbon::now()->getTimestamp()); + \Helper::queueWorkRestart(); // Sometimes processes stuck and just continue running, so we need to kill them. // Sleep to let processes stop. sleep(1); diff --git a/app/Conversation.php b/app/Conversation.php index c3a417c6f..959a03d4c 100644 --- a/app/Conversation.php +++ b/app/Conversation.php @@ -319,6 +319,20 @@ public function getLastReply() ->first(); } + /** + * Get last thread by type. + */ + public function getLastThread($types = []) + { + $query = $this->threads() + ->where('state', Thread::STATE_PUBLISHED) + ->orderBy('created_at', 'desc'); + if ($types) { + $query->whereIn('type', $types); + } + return $query->first(); + } + /** * Set preview text. * diff --git a/app/Http/Controllers/ConversationsController.php b/app/Http/Controllers/ConversationsController.php index c44af10ee..51984ae03 100644 --- a/app/Http/Controllers/ConversationsController.php +++ b/app/Http/Controllers/ConversationsController.php @@ -721,6 +721,7 @@ public function ajax(Request $request) \Helper::backgroundAction('conversation.created_by_user', [$conversation, $thread], now()->addSeconds(Conversation::UNDO_TIMOUT)); } elseif ($is_forward) { // Forward. + // Notifications to users not sent. event(new UserAddedNote($conversation, $thread)); // To send email with forwarded conversation. event(new UserReplied($forwarded_conversation, $forwarded_thread)); @@ -811,6 +812,20 @@ public function ajax(Request $request) } } + // To prevent creating draft after reply has been created. + if (!$response['msg'] && $conversation) { + // Check if the last thread has same content as the new one. + $last_thread = $conversation->getLastThread([Thread::TYPE_MESSAGE, Thread::TYPE_NOTE]); + + if ($last_thread + && $last_thread->created_by_user_id == $user->id + && $last_thread->body == $request->body + ) { + //\Log::error("You've already sent this message just recently."); + $response['msg'] = __("You've already sent this message just recently."); + } + } + // Validation is not needed on draft create, fields can be empty if (!$response['msg']) { diff --git a/app/Http/Controllers/MailboxesController.php b/app/Http/Controllers/MailboxesController.php index 0c191ce0a..90e06e771 100644 --- a/app/Http/Controllers/MailboxesController.php +++ b/app/Http/Controllers/MailboxesController.php @@ -219,6 +219,9 @@ public function connectionOutgoingSave($id, Request $request) \Option::set('send_test_to', $request->send_test_to); } + // Sometimes background job continues to use old connection settings. + \Helper::queueWorkRestart(); + \Session::flash('flash_success_floating', __('Connection settings saved!')); return redirect()->route('mailboxes.connection', ['id' => $id]); diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 9429d50ef..ac1eac258 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -107,7 +107,7 @@ public function status(Request $request) } elseif ($running_commands > 1) { // queue:work command is stopped by settings a cache key if ($command_name == 'queue:work') { - \Cache::forever('illuminate:queue:restart', Carbon::now()->getTimestamp()); + \Helper::queueWorkRestart(); $commands[] = [ 'name' => $command_name, 'status' => 'error', @@ -152,7 +152,7 @@ public function status(Request $request) // If queue:work is not running, clear cache to let it start if something is wrong with the mutex if ($command_name == 'queue:work' && !$last_successful_run && function_exists('shell_exec')) { $status_texts[] = __('Cleared cache to force command to start.'); - \Artisan::call('cache:clear'); + \Artisan::call('freescout:clear-cache'); } $commands[] = [ diff --git a/app/Listeners/SendNotificationToUsers.php b/app/Listeners/SendNotificationToUsers.php index 54c0897b6..2a1d35c98 100644 --- a/app/Listeners/SendNotificationToUsers.php +++ b/app/Listeners/SendNotificationToUsers.php @@ -36,7 +36,7 @@ public function handle($event) case 'App\Events\UserAddedNote': $caused_by_user_id = $event->thread->created_by_user_id; // When conversation is forwarded only notification - // about parent forward conversation is sent. + // about child forward conversation is sent. if (!$event->thread->isForward()) { $event_type = Subscription::EVENT_TYPE_USER_ADDED_NOTE; } diff --git a/app/Misc/Helper.php b/app/Misc/Helper.php index ad9d19d66..fe29ed913 100644 --- a/app/Misc/Helper.php +++ b/app/Misc/Helper.php @@ -6,6 +6,8 @@ namespace App\Misc; +use Carbon\Carbon; + class Helper { /** @@ -1013,4 +1015,13 @@ public static function isDefaultAppUrl($app_url) return true; } } + + /** + * Stop all queue:work processes. + */ + public static function queueWorkRestart() + { + \Cache::forever('illuminate:queue:restart', Carbon::now()->getTimestamp()); + } + } diff --git a/config/app.php b/config/app.php index fd8b24d56..b9e0cedb3 100644 --- a/config/app.php +++ b/config/app.php @@ -12,7 +12,7 @@ | or any other location as required by the application or its packages. */ - 'version' => '1.2.0', + 'version' => '1.2.1', /* |-------------------------------------------------------------------------- diff --git a/database/migrations/2019_06_25_105200_change_status_message_column_in_send_logs_table.php b/database/migrations/2019_06_25_105200_change_status_message_column_in_send_logs_table.php new file mode 100644 index 000000000..ee77c2d41 --- /dev/null +++ b/database/migrations/2019_06_25_105200_change_status_message_column_in_send_logs_table.php @@ -0,0 +1,32 @@ +text('status_message')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('send_logs', function (Blueprint $table) { + $table->string('status_message', 255)->nullable()->change(); + }); + } +} diff --git a/overrides/RachidLaasri/LaravelInstaller/Controllers/EnvironmentController.php b/overrides/RachidLaasri/LaravelInstaller/Controllers/EnvironmentController.php index 6f8d376ca..99e8cfa68 100644 --- a/overrides/RachidLaasri/LaravelInstaller/Controllers/EnvironmentController.php +++ b/overrides/RachidLaasri/LaravelInstaller/Controllers/EnvironmentController.php @@ -125,6 +125,10 @@ public function saveWizard(Request $request, Redirector $redirect) $request->database_charset = 'utf8'; $request->database_collation = 'utf8_unicode_ci'; + + $this->testDbConnect($request); + } else { + throw $e; } } } catch (\Exception $e) { diff --git a/resources/views/conversations/editor_bottom_toolbar.blade.php b/resources/views/conversations/editor_bottom_toolbar.blade.php index 674a2c033..99333714d 100644 --- a/resources/views/conversations/editor_bottom_toolbar.blade.php +++ b/resources/views/conversations/editor_bottom_toolbar.blade.php @@ -16,11 +16,11 @@ {{ __('Assign to') }}: diff --git a/resources/views/emails/customer/reply_fancy.blade.php b/resources/views/emails/customer/reply_fancy.blade.php index 89e7b9016..7381f1364 100644 --- a/resources/views/emails/customer/reply_fancy.blade.php +++ b/resources/views/emails/customer/reply_fancy.blade.php @@ -22,8 +22,9 @@ -

- @if ($loop->last){!! __(':person sent a message', ['person' => ''.htmlspecialchars($thread->getFromName($mailbox)).'']) !!}@else {!! __(':person replied', ['person' => ''.htmlspecialchars($thread->getFromName($mailbox)).'']) !!}@endif +

+ {{ $thread->getFromName($mailbox) }} + {{--if ($loop->last){!! __(':person sent a message', ['person' => ''.htmlspecialchars($thread->getFromName($mailbox)).'']) !!}@else {!! __(':person replied', ['person' => ''.htmlspecialchars($thread->getFromName($mailbox)).'']) !!}@endif--}}

@if ($thread->getCcArray()) diff --git a/resources/views/emails/customer/reply_fancy_text.blade.php b/resources/views/emails/customer/reply_fancy_text.blade.php index 776b84de2..46476c7cf 100644 --- a/resources/views/emails/customer/reply_fancy_text.blade.php +++ b/resources/views/emails/customer/reply_fancy_text.blade.php @@ -1,7 +1,7 @@ {{ App\Misc\Mail::REPLY_SEPARATOR_TEXT }} @foreach ($threads as $thread) ----------------------------------------------------------- -@if (!$loop->first)## @if ($loop->last){{ __(':person sent a message', ['person' => $thread->getFromName($mailbox)]) }}@else {{ __(':person replied', ['person' => $thread->getFromName($mailbox)]) }}@endif, {{ __('on :date', ['date' => App\Customer::dateFormat($thread->created_at, 'M j @ H:i')]) }} ({{ \Config::get('app.timezone') }}):@endif +@if (!$loop->first)## {{--@if ($loop->last){{ __(':person sent a message', ['person' => $thread->getFromName($mailbox)]) }}@else {{ __(':person replied', ['person' => $thread->getFromName($mailbox)]) }}@endif--}}{{ $thread->getFromName($mailbox) }}, {{ __('on :date', ['date' => App\Customer::dateFormat($thread->created_at, 'M j @ H:i')]) }} ({{ \Config::get('app.timezone') }}):@endif {{-- Html2Text\Html2Text::convert($thread->body) - this was causing "AttValue: " expected in Entity" error sometimes --}}{{ (new Html2Text\Html2Text($thread->body))->getText() }} @if ($thread->source_via == App\Thread::PERSON_USER) diff --git a/resources/views/mailboxes/connection.blade.php b/resources/views/mailboxes/connection.blade.php index 36623599d..a973b15c6 100644 --- a/resources/views/mailboxes/connection.blade.php +++ b/resources/views/mailboxes/connection.blade.php @@ -57,16 +57,20 @@