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 Dec 17, 2019
2 parents c822777 + f3ea9bc commit ebd34d0
Show file tree
Hide file tree
Showing 17 changed files with 280 additions and 60 deletions.
8 changes: 6 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ protected function schedule(Schedule $schedule)
}
}

$schedule->command('queue:work', Config('app.queue_work_params'))
$queue_work_params = Config('app.queue_work_params');
// Add identifier to avoid conflicts with other FreeScout instances on the same server.
$queue_work_params['--queue'] .= ','.\Helper::getWorkerIdentifier();

$schedule->command('queue:work', $queue_work_params)
->everyMinute()
->withoutOverlapping()
->sendOutputTo(storage_path().'/logs/queue-jobs.log');
Expand All @@ -154,7 +158,7 @@ protected function getRunningQueueProcesses()
$pids = [];

try {
$processes = preg_split("/[\r\n]/", shell_exec("ps aux | grep '".\Helper::WORKER_IDENTIFIER."'"));
$processes = preg_split("/[\r\n]/", shell_exec("ps aux | grep '".\Helper::getWorkerIdentifier()."'"));
foreach ($processes as $process) {
preg_match("/^[\S]+\s+([\d]+)\s+/", $process, $m);
if (!preg_match("/(sh \-c|grep )/", $process) && !empty($m[1])) {
Expand Down
2 changes: 1 addition & 1 deletion app/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ public static function clearStarredByUserCache($user_id)
*/
public static function getUserStarredConversationIds($mailbox_id, $user_id = null)
{
return \Cache::rememberForever('user_starred_conversations_'.$user_id, function () use ($mailbox_id, $user_id) {
return \Cache::rememberForever('user_starred_conversations_'.$user_id.'_'.$mailbox_id, function () use ($mailbox_id, $user_id) {
// Get user's folder
$folder = Folder::select('id')
->where('mailbox_id', $mailbox_id)
Expand Down
53 changes: 53 additions & 0 deletions app/Http/Controllers/CustomersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,57 @@ public function ajaxSearch(Request $request)

return \Response::json($response);
}

/**
* Ajax controller.
*/
public function ajax(Request $request)
{
$response = [
'status' => 'error',
'msg' => '', // this is error message
];

$user = auth()->user();

switch ($request->action) {

// Change conversation user
case 'create':
// First name or email must be specified
$validator = Validator::make($request->all(), [
'first_name' => 'required|string|max:255',
'last_name' => 'nullable|string|max:255',
'email' => 'required|email|unique:emails,email',
]);

if ($validator->fails()) {
foreach ($validator->errors()->getMessages()as $errors) {
foreach ($errors as $field => $message) {
$response['msg'] .= $message.' ';
}
}
}

if (!$response['msg']) {

$customer = Customer::create($request->email, $request->all());
if ($customer) {
$response['email'] = $request->email;
$response['status'] = 'success';
}
}
break;

default:
$response['msg'] = 'Unknown action';
break;
}

if ($response['status'] == 'error' && empty($response['msg'])) {
$response['msg'] = 'Unknown error occured';
}

return \Response::json($response);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/SystemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function status(Request $request)
// Commands
$commands_list = [
'freescout:fetch-emails' => 'freescout:fetch-emails',
\Helper::WORKER_IDENTIFIER => 'queue:work'
\Helper::getWorkerIdentifier() => 'queue:work'
];
foreach ($commands_list as $command_identifier => $command_name) {
$status_texts = [];
Expand Down
2 changes: 1 addition & 1 deletion app/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Mailbox extends Model
*
* @var [type]
*/
protected $fillable = ['name', 'slug', 'email', 'aliases', 'auto_bcc', 'from_name', 'from_name_custom', 'ticket_status', 'ticket_assignee', 'template', 'signature', 'out_method', 'out_server', 'out_username', 'out_password', 'out_port', 'out_encryption', 'in_server', 'in_port', 'in_username', 'in_password', 'in_protocol', 'in_encryption', 'in_validate_cert', 'auto_reply_enabled', 'auto_reply_subject', 'auto_reply_message', 'office_hours_enabled', 'ratings', 'ratings_placement', 'ratings_text'];
protected $fillable = ['name', 'slug', 'email', 'aliases', 'auto_bcc', 'from_name', 'from_name_custom', 'ticket_status', 'ticket_assignee', 'template', 'before_reply', 'signature', 'out_method', 'out_server', 'out_username', 'out_password', 'out_port', 'out_encryption', 'in_server', 'in_port', 'in_username', 'in_password', 'in_protocol', 'in_encryption', 'in_validate_cert', 'auto_reply_enabled', 'auto_reply_subject', 'auto_reply_message', 'office_hours_enabled', 'ratings', 'ratings_placement', 'ratings_text'];

protected static function boot()
{
Expand Down
13 changes: 8 additions & 5 deletions app/Misc/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ class Helper
*/
const QUEUE_DEFAULT = 'default';

/**
* Background worker identifier.
*/
const WORKER_IDENTIFIER = 'emails,default';

/**
* Menu structure used to display active menu item.
* Array are mnemonic names, strings - route names.
Expand Down Expand Up @@ -1263,4 +1258,12 @@ public static function isInApp()
{
return (int)app('request')->cookie('in_app');
}

/**
* Get identifier for queue:work
*/
public static function getWorkerIdentifier()
{
return md5(config('app.key'));
}
}
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.3.14',
'version' => '1.3.15',

/*
|--------------------------------------------------------------------------
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 AddBeforeReplyColumnToMailboxesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('mailboxes', function (Blueprint $table) {
$table->text('before_reply')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('mailboxes', function (Blueprint $table) {
$table->dropColumn('before_reply');
});
}
}
39 changes: 30 additions & 9 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ a.navbar-brand:hover img {
padding: 1px 11px 4px;
width: 250px;
}
.form-nav-search .input-group {
padding-top: 3px;
}
/*.navbar-nav > li > .dropdown-menu {
margin-top: -10px;
border-radius: 3px;
Expand Down Expand Up @@ -422,6 +425,10 @@ a.navbar-brand:hover img {
/**
* Forms
*/
.input-group-addon {
line-height: 11px;
background-color: transparent;
}
select.placeholdered {
color: #B4C0D4;
}
Expand Down Expand Up @@ -475,9 +482,6 @@ select.form-control {
padding-right: 7px;
position: relative;
}
.input-group {
padding-top: 3px;
}
.input-group-btn .btn {
height: 28px;
}
Expand Down Expand Up @@ -3310,7 +3314,7 @@ ul.prev-convs {
}

/**
* Sortable panel
* Panel
*/
.panel-sortable .handle {
cursor: move;
Expand All @@ -3335,10 +3339,19 @@ ul.prev-convs {
margin-bottom: 5px;
height: 41px;
}
.panel-grey {
background-color: #f8f9f9;
border-color: #dde2e6;
}

/**
* Misc
*/
.label {
font-size: 13.4px;
font-weight: normal;
padding-top: 2px;
}
.banner {
text-align: center;
margin-top: 30px;
Expand Down Expand Up @@ -3427,9 +3440,6 @@ ul.prev-convs {
.section-search {
line-height: inherit;
}
.section-search .input-group {
padding-top: 0;
}
.flexy {
display: flex;
}
Expand Down Expand Up @@ -3611,13 +3621,13 @@ a.help-icon:hover {
position: relative;
border-top-color: #a5b2bd;
}
.accordion .panel-title > a .label {
/*.accordion .panel-title > a .label {
padding-bottom: 1px;
position: relative;
padding-left: 5px;
top: -2px;
font-style: normal;
}
}*/
.accordion > .panel-default > .panel-heading {
background-color: #fff;
padding: 0;
Expand Down Expand Up @@ -3880,7 +3890,18 @@ a.disabled:focus {
.clickable {
cursor: pointer;
}
#change-customer-create .form-group {
margin-bottom: 4px;
}

/**
* Mobile
*/
@media (max-width:767px) {
.descr-block {
margin: 20px 0;
}
}
/**
* Only main content is visible
*/
Expand Down
6 changes: 5 additions & 1 deletion public/js/laroute.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@
"name": "mailboxes.ajax"
},
{
"uri": "customer\/ajax-search",
"uri": "customers\/ajax-search",
"name": "customers.ajax_search"
},
{
"uri": "customers\/ajax",
"name": "customers.ajax"
},
{
"uri": "modules\/ajax",
"name": "modules.ajax"
Expand Down
Loading

0 comments on commit ebd34d0

Please sign in to comment.