mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 15:13:29 +01:00
19080933b6
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions. You may customize the code style applied by adding a [PHP CS Fixer][1] or [PHP CodeSniffer][2] ruleset to your project root. Feel free to use [Shift's Laravel ruleset][3] to help you get started. For more information on customizing the code style applied by Shift, [watch this short video][4]. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://github.com/squizlabs/PHP_CodeSniffer [3]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 [4]: https://laravelshift.com/videos/shift-code-style
91 lines
2.8 KiB
PHP
91 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Utils\Ninja;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use LimitIterator;
|
|
use SplFileObject;
|
|
|
|
class SupportMessageSent extends Mailable
|
|
{
|
|
// use Queueable, SerializesModels;
|
|
|
|
public $data;
|
|
|
|
public $send_logs;
|
|
|
|
public function __construct(array $data, $send_logs)
|
|
{
|
|
$this->data = $data;
|
|
$this->send_logs = $send_logs;
|
|
}
|
|
|
|
/**
|
|
* Build the message.
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function build()
|
|
{
|
|
$system_info = request()->has('version') ? 'Version: '.request()->input('version') : 'Version: No Version Supplied.';
|
|
|
|
$log_lines = [];
|
|
|
|
/*
|
|
* With self-hosted version of Ninja,
|
|
* we are going to bundle system-level info
|
|
* and last 10 lines of laravel.log file.
|
|
*/
|
|
if (Ninja::isSelfHost() && $this->send_logs !== false) {
|
|
$system_info = Ninja::getDebugInfo();
|
|
|
|
$log_file = new SplFileObject(sprintf('%s/laravel.log', base_path('storage/logs')));
|
|
|
|
$log_file->seek(PHP_INT_MAX);
|
|
$last_line = $log_file->key();
|
|
|
|
$lines = new LimitIterator($log_file, max(0, $last_line - 100), $last_line);
|
|
$log_lines = iterator_to_array($lines);
|
|
}
|
|
|
|
$account = auth()->user()->account;
|
|
|
|
$priority = '';
|
|
$plan = $account->plan ?: 'customer support';
|
|
$plan = ucfirst($plan);
|
|
|
|
if (strlen($account->plan) > 1) {
|
|
$priority = '[PRIORITY] ';
|
|
}
|
|
|
|
$company = auth()->user()->company();
|
|
$user = auth()->user();
|
|
$db = str_replace('db-ninja-', '', $company->db);
|
|
$is_large = $company->is_large ? 'L' : 'S';
|
|
$platform = array_key_exists('platform', $this->data) ? $this->data['platform'] : 'U';
|
|
$migrated = strlen($company->company_key) == 32 ? 'M' : '';
|
|
$trial = $account->isTrial() ? 'T' : '';
|
|
$plan = str_replace('_', ' ', $plan);
|
|
|
|
if (Ninja::isHosted()) {
|
|
$subject = "{$priority}Hosted-{$db}-{$is_large}{$platform}{$migrated}{$trial} :: {$plan} :: ".date('M jS, g:ia');
|
|
} else {
|
|
$subject = "{$priority}Self Hosted :: {$plan} :: {$is_large}{$platform}{$migrated} :: ".date('M jS, g:ia');
|
|
}
|
|
|
|
return $this->from(config('mail.from.address'), $user->present()->name())
|
|
->replyTo($user->email, $user->present()->name())
|
|
->subject($subject)
|
|
->view('email.support.message', [
|
|
'support_message' => nl2br($this->data['message']),
|
|
'system_info' => $system_info,
|
|
'laravel_log' => $log_lines,
|
|
'logo' => $company->present()->logo(),
|
|
'settings' => $company->settings,
|
|
]);
|
|
}
|
|
}
|