2019-10-16 22:12:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Mail;
|
|
|
|
|
|
|
|
use App\Utils\Ninja;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Mail\Mailable;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
class SupportMessageSent extends Mailable
|
|
|
|
{
|
|
|
|
use Queueable, SerializesModels;
|
|
|
|
|
|
|
|
public $message;
|
|
|
|
|
|
|
|
public function __construct($message)
|
|
|
|
{
|
|
|
|
$this->message = $message;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the message.
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function build()
|
|
|
|
{
|
|
|
|
$system_info = null;
|
|
|
|
$log_lines = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* With self-hosted version of Ninja,
|
|
|
|
* we are going to bundle system-level info
|
|
|
|
* and last 10 lines of laravel.log file.
|
|
|
|
*/
|
2019-12-30 22:59:12 +01:00
|
|
|
if (Ninja::isSelfHost()) {
|
2019-10-16 22:12:38 +02:00
|
|
|
$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, $last_line - 10, $last_line);
|
|
|
|
|
|
|
|
$log_lines = iterator_to_array($lines);
|
|
|
|
}
|
|
|
|
|
2019-11-04 01:22:59 +01:00
|
|
|
return $this->from(config('mail.from.address')) //todo this needs to be fixed to handle the hosted version
|
2019-10-16 22:12:38 +02:00
|
|
|
->subject(ctrans('texts.new_support_message'))
|
|
|
|
->markdown('email.support.message', [
|
|
|
|
'message' => $this->message,
|
|
|
|
'system_info' => $system_info,
|
|
|
|
'laravel_log' => $log_lines
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|