Admin and Discord Notification Improvements (#1407)
* Backend changes Sorting for : Airlines, Subfleets, Type Ratings and exported Flights Blade : Added WYSIWYG editor to flight remarks/notes field Notifications : Mails > Added enabled/disabled settings for mails. Discord > Dashed out PirepPreFiled, re-enabled PirepStatusChanged with reduced messages * Update PirepStatusChanged.php * Update NotificationEventsHandler.php * in_array fix * Fix Discord Notifications * Discord Notifications Removed the pirep url from message as it is mostly private at phpvms side. Also removed the Flight Ident from fields 'cause it is being used in the title. Added the user avatar as thumbnail, and pirep filed message uses the airline logo as the main image. Even though the outgoing pirep status messages are reduced, it is still possible to enable/disable them from admin settings. Pirep Filed is always being sent (if the webhook is defined) * StyleFix
This commit is contained in:
@@ -410,6 +410,41 @@
|
|||||||
options: ''
|
options: ''
|
||||||
type: text
|
type: text
|
||||||
description: The Discord Webhook URL for private notifications
|
description: The Discord Webhook URL for private notifications
|
||||||
|
- key: notifications.discord_pirep_status
|
||||||
|
name: Discord Pirep Messages (Public)
|
||||||
|
group: notifications
|
||||||
|
value: true
|
||||||
|
options: ''
|
||||||
|
type: boolean
|
||||||
|
description: Pirep status messages (Only key events are being sent)
|
||||||
|
- key: notifications.mail_pirep_admin
|
||||||
|
name: Pirep Filed (Admin)
|
||||||
|
group: notifications
|
||||||
|
value: true
|
||||||
|
options: ''
|
||||||
|
type: boolean
|
||||||
|
description: Pirep filed mails sent to admins
|
||||||
|
- key: notifications.mail_pirep_user_ack
|
||||||
|
name: Pirep Accepted (Pilot)
|
||||||
|
group: notifications
|
||||||
|
value: true
|
||||||
|
options: ''
|
||||||
|
type: boolean
|
||||||
|
description: Pirep Accepted mails sent to pilots
|
||||||
|
- key: notifications.mail_pirep_user_rej
|
||||||
|
name: Pirep Rejected (Pilot)
|
||||||
|
group: notifications
|
||||||
|
value: true
|
||||||
|
options: ''
|
||||||
|
type: boolean
|
||||||
|
description: Pirep Rejected mails sent to pilots
|
||||||
|
- key: notifications.mail_news
|
||||||
|
name: News Mails
|
||||||
|
group: notifications
|
||||||
|
value: true
|
||||||
|
options: ''
|
||||||
|
type: boolean
|
||||||
|
description: News mails sent to all members
|
||||||
- key: 'cron.random_id'
|
- key: 'cron.random_id'
|
||||||
name: 'Cron Randomized ID'
|
name: 'Cron Randomized ID'
|
||||||
group: 'cron'
|
group: 'cron'
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class AirlinesController extends Controller
|
|||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$this->airlineRepo->pushCriteria(new RequestCriteria($request));
|
$this->airlineRepo->pushCriteria(new RequestCriteria($request));
|
||||||
$airlines = $this->airlineRepo->all();
|
$airlines = $this->airlineRepo->orderby('name', 'asc')->get();
|
||||||
|
|
||||||
return view('admin.airlines.index', [
|
return view('admin.airlines.index', [
|
||||||
'airlines' => $airlines,
|
'airlines' => $airlines,
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ class FlightController extends Controller
|
|||||||
$where['airline_id'] = $airline_id;
|
$where['airline_id'] = $airline_id;
|
||||||
$file_name = 'flights-'.$airline_id.'.csv';
|
$file_name = 'flights-'.$airline_id.'.csv';
|
||||||
}
|
}
|
||||||
$flights = $this->flightRepo->where($where)->get();
|
$flights = $this->flightRepo->where($where)->orderBy('airline_id')->orderBy('flight_number')->orderBy('route_code')->orderBy('route_leg')->get();
|
||||||
|
|
||||||
$path = $exporter->exportFlights($flights);
|
$path = $exporter->exportFlights($flights);
|
||||||
return response()->download($path, $file_name, ['content-type' => 'text/csv'])->deleteFileAfterSend(true);
|
return response()->download($path, $file_name, ['content-type' => 'text/csv'])->deleteFileAfterSend(true);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class SubfleetController extends Controller
|
|||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$this->subfleetRepo->with(['airline'])->pushCriteria(new RequestCriteria($request));
|
$this->subfleetRepo->with(['airline'])->pushCriteria(new RequestCriteria($request));
|
||||||
$subfleets = $this->subfleetRepo->all();
|
$subfleets = $this->subfleetRepo->orderby('name', 'asc')->get();
|
||||||
|
|
||||||
return view('admin.subfleets.index', [
|
return view('admin.subfleets.index', [
|
||||||
'subfleets' => $subfleets,
|
'subfleets' => $subfleets,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class TypeRatingController extends Controller
|
|||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$this->typeratingRepo->pushCriteria(new RequestCriteria($request));
|
$this->typeratingRepo->pushCriteria(new RequestCriteria($request));
|
||||||
$typeratings = $this->typeratingRepo->all();
|
$typeratings = $this->typeratingRepo->orderby('type', 'asc')->get();
|
||||||
|
|
||||||
return view('admin.typeratings.index', [
|
return view('admin.typeratings.index', [
|
||||||
'typeratings' => $typeratings,
|
'typeratings' => $typeratings,
|
||||||
@@ -50,7 +50,6 @@ class TypeRatingController extends Controller
|
|||||||
|
|
||||||
$model = $this->typeratingRepo->create($input);
|
$model = $this->typeratingRepo->create($input);
|
||||||
Flash::success('Type Rating saved successfully.');
|
Flash::success('Type Rating saved successfully.');
|
||||||
// Cache::forget(config('cache.keys.RANKS_PILOT_LIST.key'));
|
|
||||||
|
|
||||||
return redirect(route('admin.typeratings.edit', [$model->id]));
|
return redirect(route('admin.typeratings.edit', [$model->id]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,16 @@ use Carbon\Carbon;
|
|||||||
*/
|
*/
|
||||||
class DiscordMessage
|
class DiscordMessage
|
||||||
{
|
{
|
||||||
const COLOR_SUCCESS = '#0B6623';
|
const COLOR_SUCCESS = '0B6623';
|
||||||
const COLOR_WARNING = '#FD6A02';
|
const COLOR_WARNING = 'FD6A02';
|
||||||
const COLOR_ERROR = '#ED2939';
|
const COLOR_ERROR = 'ED2939';
|
||||||
|
|
||||||
public $webhook_url;
|
public $webhook_url;
|
||||||
|
|
||||||
protected $title;
|
protected $title;
|
||||||
protected $url;
|
protected $url;
|
||||||
|
protected $thumbnail = [];
|
||||||
|
protected $image = [];
|
||||||
protected $description;
|
protected $description;
|
||||||
protected $timestamp;
|
protected $timestamp;
|
||||||
protected $footer;
|
protected $footer;
|
||||||
@@ -26,30 +28,43 @@ class DiscordMessage
|
|||||||
protected $author = [];
|
protected $author = [];
|
||||||
protected $fields = [];
|
protected $fields = [];
|
||||||
|
|
||||||
/**
|
// Supply the webhook URL that this should be going to
|
||||||
* Supply the webhook URL that this should be going to
|
|
||||||
*/
|
|
||||||
public function webhook(string $url): self
|
public function webhook(string $url): self
|
||||||
{
|
{
|
||||||
$this->webhook_url = $url;
|
$this->webhook_url = $url;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Title of the embed
|
||||||
* Title of the notification
|
|
||||||
*/
|
|
||||||
public function title(string $title): self
|
public function title(string $title): self
|
||||||
{
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// URL of the Title
|
||||||
public function url(string $url): self
|
public function url(string $url): self
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Thumbnail image (placed right side of embed)
|
||||||
|
// ['url' => '']
|
||||||
|
public function thumbnail(array $thumbnail): self
|
||||||
|
{
|
||||||
|
$this->thumbnail = $thumbnail;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main image (placed bottom of embed)
|
||||||
|
// ['url' => '']
|
||||||
|
public function image(array $image): self
|
||||||
|
{
|
||||||
|
$this->image = $image;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|string $descriptionLines
|
* @param array|string $descriptionLines
|
||||||
*/
|
*/
|
||||||
@@ -63,22 +78,15 @@ class DiscordMessage
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Author details
|
||||||
* Set the author information:
|
// ['name' => '', 'url' => '', 'icon_url' => '']
|
||||||
* [
|
|
||||||
* 'name' => '',
|
|
||||||
* 'url' => '',
|
|
||||||
* 'icon_url' => '',
|
|
||||||
*/
|
|
||||||
public function author(array $author): self
|
public function author(array $author): self
|
||||||
{
|
{
|
||||||
$this->author = $author;
|
$this->author = $author;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Fields
|
||||||
* Set the fields
|
|
||||||
*/
|
|
||||||
public function fields(array $fields): self
|
public function fields(array $fields): self
|
||||||
{
|
{
|
||||||
$this->fields = [];
|
$this->fields = [];
|
||||||
@@ -99,32 +107,45 @@ class DiscordMessage
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixed Success Color
|
||||||
public function success(): self
|
public function success(): self
|
||||||
{
|
{
|
||||||
$this->color = static::COLOR_SUCCESS;
|
$this->color = hexdec('0B6623'); // static::COLOR_SUCCESS;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixed Warning
|
||||||
public function warning(): self
|
public function warning(): self
|
||||||
{
|
{
|
||||||
$this->color = static::COLOR_WARNING;
|
$this->color = hexdec('FD6A02'); // static::COLOR_WARNING;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixed Error
|
||||||
public function error(): self
|
public function error(): self
|
||||||
{
|
{
|
||||||
$this->color = static::COLOR_ERROR;
|
$this->color = hexdec('ED2939'); // static::COLOR_ERROR;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom Color
|
||||||
|
public function color(string $embed_color): self
|
||||||
|
{
|
||||||
|
$this->color = hexdec($embed_color);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
$embeds = [
|
$embeds = [
|
||||||
|
'type' => 'rich',
|
||||||
|
'color' => $this->color,
|
||||||
'title' => $this->title,
|
'title' => $this->title,
|
||||||
'url' => $this->url,
|
'url' => $this->url,
|
||||||
'type' => 'rich',
|
'thumbnail' => $this->thumbnail,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
'author' => $this->author,
|
'author' => $this->author,
|
||||||
|
'image' => $this->image,
|
||||||
'timestamp' => Carbon::now('UTC'),
|
'timestamp' => Carbon::now('UTC'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class NewsAdded extends Notification implements ShouldQueue
|
|||||||
public function toDiscordChannel($news): ?DiscordMessage
|
public function toDiscordChannel($news): ?DiscordMessage
|
||||||
{
|
{
|
||||||
$dm = new DiscordMessage();
|
$dm = new DiscordMessage();
|
||||||
return $dm->url(setting('notifications.discord_public_webhook_url'))
|
return $dm->webhook(setting('notifications.discord_public_webhook_url'))
|
||||||
->success()
|
->success()
|
||||||
->title('News: '.$news->subject)
|
->title('News: '.$news->subject)
|
||||||
->author([
|
->author([
|
||||||
|
|||||||
@@ -43,11 +43,10 @@ class PirepFiled extends Notification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
$title = 'Flight '.$pirep->ident.' Filed';
|
$title = 'Flight '.$pirep->ident.' Filed';
|
||||||
$fields = [
|
$fields = [
|
||||||
'Flight' => $pirep->ident,
|
'Dep.Airport' => $pirep->dpt_airport_id,
|
||||||
'Departure Airport' => $pirep->dpt_airport_id,
|
'Arr.Airport' => $pirep->arr_airport_id,
|
||||||
'Arrival Airport' => $pirep->arr_airport_id,
|
'Equipment' => $pirep->aircraft->ident,
|
||||||
'Equipment' => $pirep->aircraft->ident,
|
'Flight Time' => Time::minutesToTimeString($pirep->flight_time),
|
||||||
'Flight Time' => Time::minutesToTimeString($pirep->flight_time),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($pirep->distance) {
|
if ($pirep->distance) {
|
||||||
@@ -63,16 +62,19 @@ class PirepFiled extends Notification implements ShouldQueue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User avatar, somehow $pirep->user->resolveAvatarUrl() is not being accepted by Discord as thumbnail
|
||||||
|
$user_avatar = !empty($pirep->user->avatar) ? $pirep->user->avatar->url : $pirep->user->gravatar(256);
|
||||||
|
|
||||||
$dm = new DiscordMessage();
|
$dm = new DiscordMessage();
|
||||||
return $dm->url(setting('notifications.discord_public_webhook_url'))
|
return $dm->webhook(setting('notifications.discord_public_webhook_url'))
|
||||||
->success()
|
->success()
|
||||||
->title($title)
|
->title($title)
|
||||||
->description($pirep->user->discord_id ? 'Flight by <@'.$pirep->user->discord_id.'>' : '')
|
->description($pirep->user->discord_id ? 'Flight by <@'.$pirep->user->discord_id.'>' : '')
|
||||||
->url(route('frontend.pireps.show', [$pirep->id]))
|
->thumbnail(['url' => $user_avatar])
|
||||||
|
->image(['url' => $pirep->airline->logo])
|
||||||
->author([
|
->author([
|
||||||
'name' => $pirep->user->ident.' - '.$pirep->user->name_private,
|
'name' => $pirep->user->ident.' - '.$pirep->user->name_private,
|
||||||
'url' => route('frontend.profile.show', [$pirep->user_id]),
|
'url' => route('frontend.profile.show', [$pirep->user_id]),
|
||||||
'icon_url' => $pirep->user->resolveAvatarUrl(),
|
|
||||||
])
|
])
|
||||||
->fields($fields);
|
->fields($fields);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ use App\Notifications\Channels\Discord\DiscordMessage;
|
|||||||
use App\Notifications\Channels\Discord\DiscordWebhook;
|
use App\Notifications\Channels\Discord\DiscordWebhook;
|
||||||
use App\Support\Units\Distance;
|
use App\Support\Units\Distance;
|
||||||
use App\Support\Units\Time;
|
use App\Support\Units\Time;
|
||||||
use function config;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use PhpUnitsOfMeasure\Exception\NonNumericValue;
|
use PhpUnitsOfMeasure\Exception\NonNumericValue;
|
||||||
use PhpUnitsOfMeasure\Exception\NonStringUnitName;
|
use PhpUnitsOfMeasure\Exception\NonStringUnitName;
|
||||||
use function route;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the PIREP accepted message to a particular user, can also be sent to Discord
|
* Send the PIREP accepted message to a particular user, can also be sent to Discord
|
||||||
@@ -75,14 +73,16 @@ class PirepStatusChanged extends Notification implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function toDiscordChannel($pirep): ?DiscordMessage
|
public function toDiscordChannel($pirep): ?DiscordMessage
|
||||||
{
|
{
|
||||||
$title = 'Flight '.$pirep->ident.' '.self::$verbs[$pirep->status];
|
if (empty(setting('notifications.discord_public_webhook_url'))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = 'Flight '.$pirep->ident.' '.self::$verbs[$pirep->status];
|
||||||
$fields = [
|
$fields = [
|
||||||
'Flight' => $pirep->ident,
|
'Dep.Airport' => $pirep->dpt_airport_id,
|
||||||
'Departure Airport' => $pirep->dpt_airport_id,
|
'Arr.Airport' => $pirep->arr_airport_id,
|
||||||
'Arrival Airport' => $pirep->arr_airport_id,
|
'Equipment' => $pirep->aircraft->ident,
|
||||||
'Equipment' => $pirep->aircraft->ident,
|
'Flight Time' => Time::minutesToTimeString($pirep->flight_time),
|
||||||
'Flight Time' => Time::minutesToTimeString($pirep->flight_time),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Show the distance, but include the planned distance if it's been set
|
// Show the distance, but include the planned distance if it's been set
|
||||||
@@ -109,16 +109,29 @@ class PirepStatusChanged extends Notification implements ShouldQueue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User avatar, somehow $pirep->user->resolveAvatarUrl() is not being accepted by Discord as thumbnail
|
||||||
|
$user_avatar = !empty($pirep->user->avatar) ? $pirep->user->avatar->url : $pirep->user->gravatar(256);
|
||||||
|
|
||||||
|
// Proper coloring for the messages
|
||||||
|
// Pirep Filed > success, normals > warning, non-normals > error
|
||||||
|
$danger_types = [
|
||||||
|
PirepStatus::GRND_RTRN,
|
||||||
|
PirepStatus::DIVERTED,
|
||||||
|
PirepStatus::CANCELLED,
|
||||||
|
PirepStatus::PAUSED,
|
||||||
|
PirepStatus::EMERG_DESCENT,
|
||||||
|
];
|
||||||
|
$color = in_array($pirep->status, $danger_types, true) ? 'ED2939' : 'FD6A02';
|
||||||
|
|
||||||
$dm = new DiscordMessage();
|
$dm = new DiscordMessage();
|
||||||
return $dm->url(setting('notifications.discord_public_webhook_url'))
|
return $dm->webhook(setting('notifications.discord_public_webhook_url'))
|
||||||
->success()
|
->color($color)
|
||||||
->title($title)
|
->title($title)
|
||||||
->description($pirep->user->discord_id ? 'Flight by <@'.$pirep->user->discord_id.'>' : '')
|
->description($pirep->user->discord_id ? 'Flight by <@'.$pirep->user->discord_id.'>' : '')
|
||||||
->url(route('frontend.pireps.show', [$pirep->id]))
|
->thumbnail(['url' => $user_avatar])
|
||||||
->author([
|
->author([
|
||||||
'name' => $pirep->user->ident.' - '.$pirep->user->name_private,
|
'name' => $pirep->user->ident.' - '.$pirep->user->name_private,
|
||||||
'url' => route('frontend.profile.show', [$pirep->user_id]),
|
'url' => route('frontend.profile.show', [$pirep->user_id]),
|
||||||
'icon_url' => $pirep->user->resolveAvatarUrl(),
|
|
||||||
])
|
])
|
||||||
->fields($fields);
|
->fields($fields);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class UserRegistered extends Notification implements ShouldQueue
|
|||||||
public function toDiscordChannel($notifiable): ?DiscordMessage
|
public function toDiscordChannel($notifiable): ?DiscordMessage
|
||||||
{
|
{
|
||||||
$dm = new DiscordMessage();
|
$dm = new DiscordMessage();
|
||||||
return $dm->url(setting('notifications.discord_private_webhook_url'))
|
return $dm->webhook(setting('notifications.discord_private_webhook_url'))
|
||||||
->success()
|
->success()
|
||||||
->title('New User Registered: '.$this->user->ident)
|
->title('New User Registered: '.$this->user->ident)
|
||||||
->author([
|
->author([
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Events\PirepRejected;
|
|||||||
use App\Events\PirepStatusChange;
|
use App\Events\PirepStatusChange;
|
||||||
use App\Events\UserRegistered;
|
use App\Events\UserRegistered;
|
||||||
use App\Events\UserStateChanged;
|
use App\Events\UserStateChanged;
|
||||||
|
use App\Models\Enums\PirepStatus;
|
||||||
use App\Models\Enums\UserState;
|
use App\Models\Enums\UserState;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\Messages\UserRejected;
|
use App\Notifications\Messages\UserRejected;
|
||||||
@@ -161,7 +162,7 @@ class NotificationEventsHandler extends Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefile notification
|
* Prefile notification. Disabled intentionally, No need to send it to Discord
|
||||||
*/
|
*/
|
||||||
public function onPirepPrefile(PirepPrefiled $event): void
|
public function onPirepPrefile(PirepPrefiled $event): void
|
||||||
{
|
{
|
||||||
@@ -170,16 +171,33 @@ class NotificationEventsHandler extends Listener
|
|||||||
/*
|
/*
|
||||||
* Broadcast notifications
|
* Broadcast notifications
|
||||||
*/
|
*/
|
||||||
Notification::send([$event->pirep], new Messages\Broadcast\PirepPrefiled($event->pirep));
|
// Notification::send([$event->pirep], new Messages\Broadcast\PirepPrefiled($event->pirep));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status Change notification. Disabled for now, too noisy
|
* Status Change notification.
|
||||||
|
* Reduced the messages (Boarding, Pushback, TakeOff, Landing and non-normals only)
|
||||||
|
* If needed array can be tied to a setting at admin side for further customization
|
||||||
*/
|
*/
|
||||||
public function onPirepStatusChange(PirepStatusChange $event): void
|
public function onPirepStatusChange(PirepStatusChange $event): void
|
||||||
{
|
{
|
||||||
// Log::info('NotificationEvents::onPirepStatusChange: '.$event->pirep->id.' prefiled');
|
Log::info('NotificationEvents::onPirepStatusChange: '.$event->pirep->id.' status changed');
|
||||||
// Notification::send([$event->pirep], new Messages\Discord\PirepStatusChanged($event->pirep));
|
|
||||||
|
$message_types = [
|
||||||
|
PirepStatus::BOARDING,
|
||||||
|
PirepStatus::PUSHBACK_TOW,
|
||||||
|
PirepStatus::GRND_RTRN,
|
||||||
|
PirepStatus::TAKEOFF,
|
||||||
|
PirepStatus::LANDED,
|
||||||
|
PirepStatus::DIVERTED,
|
||||||
|
PirepStatus::CANCELLED,
|
||||||
|
PirepStatus::PAUSED,
|
||||||
|
PirepStatus::EMERG_DESCENT,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (setting('notifications.discord_pirep_status', true) && in_array($event->pirep->status, $message_types, true)) {
|
||||||
|
Notification::send([$event->pirep], new Messages\Broadcast\PirepStatusChanged($event->pirep));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -190,7 +208,9 @@ class NotificationEventsHandler extends Listener
|
|||||||
public function onPirepFile(PirepFiled $event): void
|
public function onPirepFile(PirepFiled $event): void
|
||||||
{
|
{
|
||||||
Log::info('NotificationEvents::onPirepFile: '.$event->pirep->id.' filed');
|
Log::info('NotificationEvents::onPirepFile: '.$event->pirep->id.' filed');
|
||||||
$this->notifyAdmins(new Messages\PirepFiled($event->pirep));
|
if (setting('notifications.mail_pirep_admin', true)) {
|
||||||
|
$this->notifyAdmins(new Messages\PirepFiled($event->pirep));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Broadcast notifications
|
* Broadcast notifications
|
||||||
@@ -205,8 +225,10 @@ class NotificationEventsHandler extends Listener
|
|||||||
*/
|
*/
|
||||||
public function onPirepAccepted(PirepAccepted $event): void
|
public function onPirepAccepted(PirepAccepted $event): void
|
||||||
{
|
{
|
||||||
Log::info('NotificationEvents::onPirepAccepted: '.$event->pirep->id.' accepted');
|
if (setting('notifications.mail_pirep_user_ack', true)) {
|
||||||
$this->notifyUser($event->pirep->user, new Messages\PirepAccepted($event->pirep));
|
Log::info('NotificationEvents::onPirepAccepted: '.$event->pirep->id.' accepted');
|
||||||
|
$this->notifyUser($event->pirep->user, new Messages\PirepAccepted($event->pirep));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -216,8 +238,10 @@ class NotificationEventsHandler extends Listener
|
|||||||
*/
|
*/
|
||||||
public function onPirepRejected(PirepRejected $event): void
|
public function onPirepRejected(PirepRejected $event): void
|
||||||
{
|
{
|
||||||
Log::info('NotificationEvents::onPirepRejected: '.$event->pirep->id.' rejected');
|
if (setting('notifications.mail_pirep_user_rej', true)) {
|
||||||
$this->notifyUser($event->pirep->user, new Messages\PirepRejected($event->pirep));
|
Log::info('NotificationEvents::onPirepRejected: '.$event->pirep->id.' rejected');
|
||||||
|
$this->notifyUser($event->pirep->user, new Messages\PirepRejected($event->pirep));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -228,7 +252,9 @@ class NotificationEventsHandler extends Listener
|
|||||||
public function onNewsAdded(NewsAdded $event): void
|
public function onNewsAdded(NewsAdded $event): void
|
||||||
{
|
{
|
||||||
Log::info('NotificationEvents::onNewsAdded');
|
Log::info('NotificationEvents::onNewsAdded');
|
||||||
$this->notifyAllUsers(new Messages\NewsAdded($event->news));
|
if (setting('notifications.mail_news', true)) {
|
||||||
|
$this->notifyAllUsers(new Messages\NewsAdded($event->news));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Broadcast notifications
|
* Broadcast notifications
|
||||||
|
|||||||
@@ -174,7 +174,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
@@ -260,8 +259,9 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-sm-12">
|
<div class="form-group col-sm-12">
|
||||||
{{ Form::textarea('notes', null, [
|
{{ Form::textarea('notes', null, [
|
||||||
'class' => 'form-control input-text',
|
'id' => 'editor',
|
||||||
'style' => 'padding: 10px',
|
'class' => 'editor',
|
||||||
|
'style' => 'padding: 5px',
|
||||||
]) }}
|
]) }}
|
||||||
<p class="text-danger">{{ $errors->first('notes') }}</p>
|
<p class="text-danger">{{ $errors->first('notes') }}</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -288,3 +288,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@section('scripts')
|
||||||
|
@parent
|
||||||
|
<script src="{{ public_asset('assets/vendor/ckeditor4/ckeditor.js') }}"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () { CKEDITOR.replace('editor'); });
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
Reference in New Issue
Block a user