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 Jun 27, 2019
2 parents b87892d + 290d6d8 commit b9f3d87
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions app/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
15 changes: 15 additions & 0 deletions app/Http/Controllers/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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']) {
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/MailboxesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/SystemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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[] = [
Expand Down
2 changes: 1 addition & 1 deletion app/Listeners/SendNotificationToUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 11 additions & 0 deletions app/Misc/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace App\Misc;

use Carbon\Carbon;

class Helper
{
/**
Expand Down Expand Up @@ -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());
}

}
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.2.0',
'version' => '1.2.1',

/*
|--------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class ChangeStatusMessageColumnInSendLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('send_logs', function (Blueprint $table) {
$table->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();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions resources/views/conversations/editor_bottom_toolbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<small class="note-bottom-div"></small>
<span class="editor-btm-text">{{ __('Assign to') }}:</span>
<select name="user_id" class="form-control" data-parsley-exclude="true">
<option value="-1" @if (!$conversation->user_id && $mailbox->ticket_assignee == App\Mailbox::TICKET_ASSIGNEE_ANYONE))data-default="true" selected="selected"@endif>{{ __('Anyone') }}</option>
<option value="{{ Auth::user()->id }}" @if (($conversation->user_id == Auth::user()->id || (!$conversation->user_id && $mailbox->ticket_assignee == App\Mailbox::TICKET_ASSIGNEE_REPLYING_UNASSIGNED)) || $mailbox->ticket_assignee == App\Mailbox::TICKET_ASSIGNEE_REPLYING)data-default="true" selected="selected"@endif>{{ __('Me') }}</option>
<option value="-1" @if ($mailbox->ticket_assignee == App\Mailbox::TICKET_ASSIGNEE_ANYONE)data-default="true" selected="selected"@endif>{{ __('Anyone') }}</option>
<option value="{{ Auth::user()->id }}" @if (($conversation->user_id == Auth::user()->id && !$mailbox->ticket_assignee == App\Mailbox::TICKET_ASSIGNEE_ANYONE) || (!$conversation->user_id && $mailbox->ticket_assignee == App\Mailbox::TICKET_ASSIGNEE_REPLYING_UNASSIGNED) || $mailbox->ticket_assignee == App\Mailbox::TICKET_ASSIGNEE_REPLYING)data-default="true" selected="selected"@endif>{{ __('Me') }}</option>
@foreach ($mailbox->usersHavingAccess() as $user)
@if ($user->id != Auth::user()->id)
<option value="{{ $user->id }}" @if ($conversation->user_id == $user->id || $mailbox->ticket_assignee == App\Mailbox::TICKET_ASSIGNEE_REPLYING_UNASSIGNED)data-default="true" selected="selected"@endif>{{ $user->getFullName() }}</option>
<option value="{{ $user->id }}" @if ($conversation->user_id == $user->id && !in_array($mailbox->ticket_assignee, [ App\Mailbox::TICKET_ASSIGNEE_REPLYING, App\Mailbox::TICKET_ASSIGNEE_ANYONE]))data-default="true" selected="selected"@endif>{{ $user->getFullName() }}</option>
@endif
@endforeach
</select>
Expand Down
5 changes: 3 additions & 2 deletions resources/views/emails/customer/reply_fancy.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
<tr>
<td style="padding:8px 0 10px 0;">

<h3 style="font-family:Arial, 'Helvetica Neue', Helvetica, Tahoma, sans-serif; color:#727272; font-size:16px; line-height:22px; margin:0; font-weight:normal;">
@if ($loop->last){!! __(':person sent a message', ['person' => '<strong style="color:#000000;">'.htmlspecialchars($thread->getFromName($mailbox)).'</strong>']) !!}@else {!! __(':person replied', ['person' => '<strong style="color:#000000;">'.htmlspecialchars($thread->getFromName($mailbox)).'</strong>']) !!}@endif
<h3 style="font-family:Arial, 'Helvetica Neue', Helvetica, Tahoma, sans-serif; color:#727272; font-size:15px; line-height:21px; margin:0; font-weight:normal;">
<strong style="color:#000000;">{{ $thread->getFromName($mailbox) }}</strong>
{{--if ($loop->last){!! __(':person sent a message', ['person' => '<strong style="color:#000000;">'.htmlspecialchars($thread->getFromName($mailbox)).'</strong>']) !!}@else {!! __(':person replied', ['person' => '<strong style="color:#000000;">'.htmlspecialchars($thread->getFromName($mailbox)).'</strong>']) !!}@endif--}}
</h3>

@if ($thread->getCcArray())
Expand Down
2 changes: 1 addition & 1 deletion resources/views/emails/customer/reply_fancy_text.blade.php
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
16 changes: 10 additions & 6 deletions resources/views/mailboxes/connection.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,20 @@
<div class="control-group text-help margin-top-10">
<ul>
<li>
<a href="https://aws.amazon.com/ses/pricing/" target="_blank">Amazon SES</a><br/>
<span class="text-help">{!! __("62,000 free emails per month from :%a_begin%Amazon EC2:%a_end% server", ['%a_begin%' => '<a href="https://aws.amazon.com/ec2/" target="_blank">', '%a_end%' => '</a>']) !!}</span>
<a href="https://aws.amazon.com/ses/pricing/" target="_blank">Amazon SES</a> -
<span class="text-help">{!! __("62,000 free emails per month from :%a_begin%Amazon EC2:%a_end% server.", ['%a_begin%' => '<a href="https://aws.amazon.com/ec2/" target="_blank">', '%a_end%' => '</a>']) !!}</span>
</li>
<li>
<a href="https://www.mailgun.com" target="_blank">Mailgun</a><br/>
<span class="text-help">{{ __("10,000 free emails per month") }}</span>
<a href="https://www.mailgun.com" target="_blank">Mailgun</a> -
<span class="text-help">{{ __(":number free emails per month.", ['number' => '10,000']) }}</span>
</li>
<li>
<a href="https://www.sendinblue.com/?tap_a=30591-fb13f0&tap_s=294678-0b81e5" target="_blank">SendinBlue</a><br/>
<span class="text-help">{{ __("9,000 free emails per month") }}</span>
<a href="https://www.sendinblue.com/?tap_a=30591-fb13f0&tap_s=294678-0b81e5" target="_blank">SendinBlue</a> -
<span class="text-help">{{ __(":number free emails per month.", ['number' => '9,000']) }}</span>
</li>
<li>
<a href="https://www.mailjet.com/?tap_a=25852-4bddf6&tap_s=545617-55177a&aff=545617-55177a" target="_blank">Mailjet</a> -
<span class="text-help">{{ __(":number free emails per month.", ['number' => '6,000']) }}</span>
</li>
</ul>
</div>
Expand Down

0 comments on commit b9f3d87

Please sign in to comment.