Skip to content

Commit

Permalink
Merge pull request #127 from vatsimnetwork/development
Browse files Browse the repository at this point in the history
1.7.0
  • Loading branch information
lieselwd authored Sep 2, 2024
2 parents ead0ab2 + ee04da3 commit 89fe60c
Show file tree
Hide file tree
Showing 31 changed files with 2,949 additions and 2,423 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ SENTRY_LARAVEL_DSN=
SENTRY_TRACES_SAMPLE_RATE=1.0

RCL_TIME_CONSTRAINTS_ENABLED=true
RCL_AUTO_ACKNOWLEDGEMENT_ENABLED=false
RCL_LOWER_LIMIT=14
RCL_UPPER_LIMIT=91
3 changes: 3 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ protected function schedule(Schedule $schedule)
if (config('services.pruning.prune_msgs')) {
$schedule->command('model:prune')->hourly();
}

// Clean activity log
$schedule->command('activitylog:clean')->daily();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions app/Enums/DatalinkAuthorities.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ enum DatalinkAuthorities: string
case TTZO = 'TTZO';
case CZQXD = 'CZQX';
case CZQMD = 'CZQM';
case SYS = 'SYST';
case OCEN = 'OCEN';

public function description(): string
{
Expand All @@ -26,6 +28,8 @@ public function description(): string
DatalinkAuthorities::KZNY => 'New York',
DatalinkAuthorities::CZQMD => 'Moncton (Domestic)',
DatalinkAuthorities::CZQXD => 'Gander (Domestic)',
DatalinkAuthorities::SYS => 'natTrak System',
DatalinkAuthorities::OCEN => 'Oceanic Controller',
default => 'N/A'
};
}
Expand Down
28 changes: 28 additions & 0 deletions app/Enums/DomesticAuthorities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Enums;

enum DomesticAuthorities: string
{
case EISN = 'EISN';
case LPPC = 'LPPC';
case LFRR = 'LFRR';
case EGTT = 'EGTT';
case CZQMD = 'CZQM';
case CZQXD = 'CZQX';
case UNKN = 'UNKN';

public function description(): string
{
return match ($this) {
DomesticAuthorities::EISN => 'Shannon',
DomesticAuthorities::LPPC => 'Lisbon',
DomesticAuthorities::LFRR => 'Brest',
DomesticAuthorities::EGTT => 'London',
DomesticAuthorities::CZQMD => 'Moncton',
DomesticAuthorities::CZQXD => 'Moncton/Gander',
DomesticAuthorities::UNKN => 'Unknown',
default => 'Unknown',
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Enums;

enum RclErrorsEnum: string
enum RclResponsesEnum: string
{
case TooEarly = "RCL REJECTED\nRCL SENT TOO EARLY";
case TooLate = "RCL REJECTED\nRCL RECEIVED TOO LATE REVERT TO VOICE PROCEDURES";
Expand All @@ -11,6 +11,7 @@ enum RclErrorsEnum: string
case Cancelled = "RCL/CLA REJECTED\nCLEARANCE CALLED REVERT TO VOICE PROCEDURES";
case Invalid = "RCL REJECTED\nINVAILD %s\nRESUBMIT YOUR REQUEST";
case Contact = "RCL/CLA RECEIVED\nCONTACT %s BY VOICE";
case Acknowledge = "RCL/CLA RECEIVED\nFLY CURRENT FLIGHT PLAN OR AS AMENDED BY ATC\nCONTINUE TO MONITOR NATTRAK UNTIL ENTERING OCA";

public function text(): string
{
Expand All @@ -21,7 +22,8 @@ public function text(): string
self::Negotiation => 'Negotiation of your clearance with the controller is required. Contact the controller specified via voice.',
self::Cancelled => 'Clearance cancelled by the controller. Revert to voice or check private messages in pilot client.',
self::Invalid => 'Check the identified error, amend and re-submit. For help contact the controller.',
self::Contact => 'Revert to voice.'
self::Contact => 'Revert to voice.',
self::Acknowledge => 'Request acknowledged. Continue as planned. Monitor natTrak for ATC amendments.'
};
}
}
5 changes: 5 additions & 0 deletions app/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use App\Services\VatsimDataService;
use Illuminate\Support\Facades\Auth;

function system_user_id(): int
{
return 9999999;
}

function current_tmi(): int|string
{
if ($tmi = config('services.tracks.override_tmi')) {
Expand Down
16 changes: 13 additions & 3 deletions app/Http/Controllers/ClxMessagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Enums\ClxCancellationReasons;
use App\Enums\DatalinkAuthorities;
use App\Enums\RclErrorsEnum;
use App\Enums\RclResponsesEnum;
use App\Events\ClxIssuedEvent;
use App\Http\Requests\ClxMessageRequest;
use App\Models\ClxMessage;
Expand Down Expand Up @@ -280,12 +280,22 @@ public function revertToVoice(Request $request, RclMessage $rclMessage)
author: $datalinkAuthority,
recipient: $rclMessage->callsign,
recipientAccount: $rclMessage->vatsimAccount,
message: sprintf(RclErrorsEnum::Contact->value, strtoupper($datalinkAuthority->description())),
caption: RclErrorsEnum::Contact->text()
message: sprintf(RclResponsesEnum::Contact->value, strtoupper($datalinkAuthority->description())),
caption: RclResponsesEnum::Contact->text()
);

flashAlert(type: 'success', title: null, message: 'Revert to voice message sent. You can delete the request now.', toast: true, timer: true);

return redirect()->route('controllers.clx.show-rcl-message', $rclMessage);
}

public function create()
{
return view('controllers.clx.rcl-messages.create', [
'dlAuthorities' => DatalinkAuthorities::cases(),
'tracks' => Track::where('active', true)->orWhere('concorde', true)->get(),
'activeDlAuthority' => $this->dataService->getActiveControllerAuthority(Auth::user()) ?? DatalinkAuthorities::NAT,
'_pageTitle' => 'Create Manual Clearance',
]);
}
}
18 changes: 17 additions & 1 deletion app/Http/Controllers/RclMessagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

namespace App\Http\Controllers;

use App\Enums\DatalinkAuthorities;
use App\Enums\RclResponsesEnum;
use App\Http\Requests\RclMessageRequest;
use App\Models\RclMessage;
use App\Models\Track;
use App\Services\CpdlcService;
use App\Services\VatsimDataService;
use Illuminate\Support\Facades\Auth;

class RclMessagesController extends Controller
{
private $dataService;
public CpdlcService $cpdlcService;

public function __construct(VatsimDataService $vatsimDataService)
public function __construct(VatsimDataService $vatsimDataService, CpdlcService $cpdlcService)
{
$this->dataService = $vatsimDataService;
$this->cpdlcService = $cpdlcService;
}

public function index()
Expand Down Expand Up @@ -53,6 +58,17 @@ public function store(RclMessageRequest $request)
}
$rclMessage->save();

// If RCL auto acknowledgement enabled, send CPDLC acknowledgement
if (config('app.rcl_auto_acknowledgement_enabled')) {
$this->cpdlcService->sendMessage(
author: DatalinkAuthorities::SYS,
recipient: $rclMessage->callsign,
recipientAccount: $rclMessage->vatsimAccount,
message: sprintf(RclResponsesEnum::Acknowledge->value, strtoupper(DatalinkAuthorities::SYS->description())),
caption: RclResponsesEnum::Acknowledge->text()
);
}

return redirect()->route('pilots.message-history');
}
}
4 changes: 4 additions & 0 deletions app/Http/Livewire/Controllers/ConflictChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function levelChanged(string $newLevel)

public function timeChanged(string $newTime)
{
if (strlen($newTime) != 4) return;
if (empty($newTime)) {
$this->time = $this->originalTime;
} else {
Expand Down Expand Up @@ -189,6 +190,9 @@ private function mapRclMessages(Collection $messages): Collection

public function check()
{
if (strlen($this->time) != 4) {
return;
}
/**
* Set cleared conflicts (CLX messages) to null, fetch them from DB, map them to array, determine conflict level, then set public variable.
*/
Expand Down
Loading

0 comments on commit 89fe60c

Please sign in to comment.