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:
@@ -43,11 +43,10 @@ class PirepFiled extends Notification implements ShouldQueue
|
||||
{
|
||||
$title = 'Flight '.$pirep->ident.' Filed';
|
||||
$fields = [
|
||||
'Flight' => $pirep->ident,
|
||||
'Departure Airport' => $pirep->dpt_airport_id,
|
||||
'Arrival Airport' => $pirep->arr_airport_id,
|
||||
'Equipment' => $pirep->aircraft->ident,
|
||||
'Flight Time' => Time::minutesToTimeString($pirep->flight_time),
|
||||
'Dep.Airport' => $pirep->dpt_airport_id,
|
||||
'Arr.Airport' => $pirep->arr_airport_id,
|
||||
'Equipment' => $pirep->aircraft->ident,
|
||||
'Flight Time' => Time::minutesToTimeString($pirep->flight_time),
|
||||
];
|
||||
|
||||
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();
|
||||
return $dm->url(setting('notifications.discord_public_webhook_url'))
|
||||
return $dm->webhook(setting('notifications.discord_public_webhook_url'))
|
||||
->success()
|
||||
->title($title)
|
||||
->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([
|
||||
'name' => $pirep->user->ident.' - '.$pirep->user->name_private,
|
||||
'url' => route('frontend.profile.show', [$pirep->user_id]),
|
||||
'icon_url' => $pirep->user->resolveAvatarUrl(),
|
||||
'name' => $pirep->user->ident.' - '.$pirep->user->name_private,
|
||||
'url' => route('frontend.profile.show', [$pirep->user_id]),
|
||||
])
|
||||
->fields($fields);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user