Skip to content

Commit

Permalink
Merge pull request #27 from freescout-helpdesk/analysis-qvBpwN
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
freescout-helpdesk authored Aug 8, 2018
2 parents 784fc13 + 40642fb commit 2c9e0e6
Show file tree
Hide file tree
Showing 21 changed files with 79 additions and 73 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/FetchEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function fetch($mailbox)
$prev_thread = null;
$in_reply_to = $message->getInReplyTo();
$references = $message->getReferences();

if ($in_reply_to) {
$prev_thread = Thread::where('message_id', $in_reply_to)->first();
} elseif ($references) {
Expand Down
3 changes: 2 additions & 1 deletion app/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public function getReplies()

/**
* Get all published conversation thread in desc order.
*
* @return Collection
*/
public function getThreads($skip = null, $take = null)
Expand Down Expand Up @@ -282,7 +283,7 @@ public function isActive()

/**
* Get status name.
*
*
* @return string
*/
public function getStatusName()
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use App\Conversation;
use App\Customer;
use App\Events\UserCreatedConversation;
use App\Events\ConversationStatusChanged;
use App\Events\ConversationUserChanged;
use App\Events\UserCreatedConversation;
use App\Events\UserReplied;
use App\Folder;
use App\Mailbox;
Expand Down
13 changes: 7 additions & 6 deletions app/Http/Controllers/SecureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ public function system(Request $request)
$commands_list = ['freescout:fetch-emails', 'queue:work'];
foreach ($commands_list as $command_name) {
$status_texts = [];

// Check if command is running now
if (function_exists('shell_exec')) {
$running_commands = 0;

try {
$processes = preg_split("/[\r\n]/", shell_exec("ps aux | grep '{$command_name}'"));
$pids = [];
Expand All @@ -140,22 +141,22 @@ public function system(Request $request)
if ($running_commands == 1) {
$commands[] = [
'name' => $command_name,
'status' => "success",
'status' => 'success',
'status_text' => __('Running'),
];
continue;
} elseif ($running_commands > 1) {
unset($pids[0]);
$commands[] = [
'name' => $command_name,
'status' => "error",
'status' => 'error',
'status_text' => __(':number commands are running at the same time. Please stop extra commands by executing the following console command:', ['number' => $running_commands]).' kill '.implode(' | kill ', $pids),
];
continue;
}
}
// Check last run
$option_name = str_replace('freescout_', '', preg_replace("/[^a-zA-Z0-9]/", '_', $command_name));
$option_name = str_replace('freescout_', '', preg_replace('/[^a-zA-Z0-9]/', '_', $command_name));

$date_text = '?';
$last_run = Option::get($option_name.'_last_run');
Expand All @@ -174,15 +175,15 @@ public function system(Request $request)
$status_texts[] = __('Last successful run:').' '.$date_text;

$status = 'error';
if ($last_successful_run && $last_run && (int)$last_successful_run >= (int)$last_run) {
if ($last_successful_run && $last_run && (int) $last_successful_run >= (int) $last_run) {
unset($status_texts[0]);
$status = 'success';
}

$commands[] = [
'name' => $command_name,
'status' => $status,
'status_text' => implode(' / ', $status_texts)
'status_text' => implode(' / ', $status_texts),
];
}

Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Http\Controllers;

use App\Mailbox;
use App\User;
use App\Subscription;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Validator;
Expand Down Expand Up @@ -198,7 +198,7 @@ public function notifications($id)
}

return view('users/notifications', [
'user' => $user,
'user' => $user,
'subscriptions' => $subscriptions,
'person' => $person,
]);
Expand All @@ -207,7 +207,7 @@ public function notifications($id)
/**
* Save user notifications settings.
*
* @param int $id
* @param int $id
* @param \Illuminate\Http\Request $request
*/
public function notificationsSave($id, Request $request)
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Middleware/TerminateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use App\Subscription;
use Closure;

class TerminateHandler {

public function handle($request, Closure $next)
class TerminateHandler
{
public function handle($request, Closure $next)
{
return $next($request);
}
Expand Down
1 change: 0 additions & 1 deletion app/Jobs/SendNotificationToUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Mail\UserNotification;
use App\SendLog;
use App\Thread;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
Expand Down
1 change: 0 additions & 1 deletion app/Listeners/SendNotificationToUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function __construct()

/**
* Handle the event.
*
*/
public function handle($event)
{
Expand Down
1 change: 0 additions & 1 deletion app/Listeners/SendReplyToCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function __construct()

/**
* Handle the event.
*
*/
public function handle($event)
{
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
4 changes: 1 addition & 3 deletions app/Mail/UserNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Container\Container;
use Illuminate\Contracts\Mail\Mailer as MailerContract;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

Expand Down Expand Up @@ -79,7 +77,7 @@ public function build()
});
}

$subject = '[#'.$this->conversation->number.'] ' .$this->conversation->subject;
$subject = '[#'.$this->conversation->number.'] '.$this->conversation->subject;

$customer = $this->conversation->customer;

Expand Down
14 changes: 7 additions & 7 deletions app/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class Mailbox extends Model

public static $out_encryptions = [
self::OUT_ENCRYPTION_NONE => '',
self::OUT_ENCRYPTION_SSL => 'ssl',
self::OUT_ENCRYPTION_TLS => 'tls',
self::OUT_ENCRYPTION_SSL => 'ssl',
self::OUT_ENCRYPTION_TLS => 'tls',
];

/**
Expand All @@ -76,8 +76,8 @@ class Mailbox extends Model

public static $in_encryptions = [
self::IN_ENCRYPTION_NONE => '',
self::IN_ENCRYPTION_SSL => 'ssl',
self::IN_ENCRYPTION_TLS => 'tls',
self::IN_ENCRYPTION_SSL => 'ssl',
self::IN_ENCRYPTION_TLS => 'tls',
];

/**
Expand Down Expand Up @@ -380,7 +380,7 @@ public function getEmailDomain()

/**
* Get outgoing email encryption protocol.
*
*
* @return string
*/
public function getOutEncryptionName()
Expand All @@ -390,7 +390,7 @@ public function getOutEncryptionName()

/**
* Get incoming email encryption protocol.
*
*
* @return string
*/
public function getInEncryptionName()
Expand All @@ -400,7 +400,7 @@ public function getInEncryptionName()

/**
* Get incoming protocol name.
*
*
* @return string
*/
public function getInProtocolName()
Expand Down
2 changes: 1 addition & 1 deletion app/Observers/UserObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UserObserver
public function created(User $user)
{
// We can not create user folders here, as user is not connected to mailboxes yet

// Add default subscriptions
Subscription::addDefaultSubscriptions($user->id);
}
Expand Down
19 changes: 11 additions & 8 deletions app/Option.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
/**
* todo: implement caching by saving all options in one cache variable on register_shutdown_function
* todo: implement caching by saving all options in one cache variable on register_shutdown_function.
*/

namespace App;

use Illuminate\Database\Eloquent\Model;
Expand All @@ -16,16 +17,18 @@ class Option extends Model
* @var array
*/
protected $guarded = ['id'];

/**
* Set an option.
*
* @param string $name
* @param string $value
* @return boolean
* @param string $name
* @param string $value
*
* @return bool
*/
public static function set($name, $value)
{
$option = Option::firstOrCreate(
$option = self::firstOrCreate(
['name' => $name], ['value' => $value]
);
if ($option['value'] != $value) {
Expand All @@ -37,17 +40,17 @@ public static function set($name, $value)
/**
* Get option.
*
* @param string $name
* @param string $name
*
* @return string
*/
public static function get($name, $default = false)
{
$option = Option::where('name', (string) $name)->first();
$option = self::where('name', (string) $name)->first();
if ($option) {
return $option->value;
} else {
return $default;
}
}

}
19 changes: 10 additions & 9 deletions app/SendLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* Outgoing emails.
*/

namespace App;

use Illuminate\Database\Eloquent\Model;
Expand All @@ -10,16 +11,16 @@ class SendLog extends Model
{
/**
* Status of the email sent to the customer or user.
* https://documentation.mailgun.com/en/latest/api-events.html#event-types
* https://documentation.mailgun.com/en/latest/api-events.html#event-types.
*/
const STATUS_ACCEPTED = 1; // accepted (for delivery)
const STATUS_SEND_ERROR = 2;
const STATUS_DELIVERY_SUCCESS = 4;
const STATUS_DELIVERY_ERROR = 5; // rejected, failed
const STATUS_OPENED = 6;
const STATUS_CLICKED = 7;
const STATUS_UNSUBSCRIBED = 8;
const STATUS_COMPLAINED = 9;
const STATUS_ACCEPTED = 1; // accepted (for delivery)
const STATUS_SEND_ERROR = 2;
const STATUS_DELIVERY_SUCCESS = 4;
const STATUS_DELIVERY_ERROR = 5; // rejected, failed
const STATUS_OPENED = 6;
const STATUS_CLICKED = 7;
const STATUS_UNSUBSCRIBED = 8;
const STATUS_COMPLAINED = 9;

/**
* The attributes that are not mass assignable.
Expand Down
3 changes: 1 addition & 2 deletions app/Sendmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* Outgoing emails.
*/

namespace App;

use Illuminate\Database\Eloquent\Model;
Expand Down Expand Up @@ -30,6 +31,4 @@ public function user()
{
return $this->belongsTo('App\User');
}


}
Loading

0 comments on commit 2c9e0e6

Please sign in to comment.