Skip to content

Commit

Permalink
Merge pull request #167 from vatsimnetwork/fix-dl-authority
Browse files Browse the repository at this point in the history
  • Loading branch information
williammck authored Nov 29, 2024
2 parents d2efd48 + 23ab6b8 commit e9ba7a8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
5 changes: 3 additions & 2 deletions app/Console/Commands/AutoAcknowledgeClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Enums\DatalinkAuthorities;
use App\Enums\RclResponsesEnum;
use App\Models\ClxMessage;
use App\Models\DatalinkAuthority;
use App\Models\RclMessage;
use App\Services\CpdlcService;
use Illuminate\Console\Command;
Expand All @@ -23,7 +24,7 @@ public function handle(): void
if ($rclMessage->isEditLocked()) {
continue;
}
$datalinkAuthority = DatalinkAuthorities::SYS;
$datalinkAuthority = DatalinkAuthority::find('SYST');
$cpdlcService = new CpdlcService();
$cpdlcService->sendMessage(
author: $datalinkAuthority,
Expand All @@ -43,7 +44,7 @@ public function handle(): void
'entry_time_restriction' => null,
'raw_entry_time_restriction' => $rclMessage->entry_time,
'free_text' => "** AUTO ACKNOWLEDGE **",
'datalink_authority' => $datalinkAuthority,
'datalink_authority_id' => $datalinkAuthority->id,
'is_concorde' => $rclMessage->is_concorde,
'simple_datalink_message' => '** AUTO ACKNOWLEDGED REFER RCL REQUEST **',
'datalink_message' => ['** AUTO ACKNOWLEDGED REFER RCL REQUEST **'],
Expand Down
4 changes: 2 additions & 2 deletions app/Helpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use App\Enums\DatalinkAuthorities;
use App\Models\DatalinkAuthority;
use App\Services\TracksService;
use App\Services\VatsimDataService;
use Illuminate\Support\Facades\Auth;
Expand All @@ -23,7 +23,7 @@ function current_tmi(): int|string
});
}

function current_dl_authority(): ?DatalinkAuthorities
function current_dl_authority(): ?DatalinkAuthority
{
$dataService = new VatsimDataService();

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/PluginDataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function detailedClxMessages(Request $request)
'controller' => [
'cid' => $msg->vatsimAccount->id ?? null,
'callsign' => $this->dataService->getActiveControllerData($msg->vatsimAccount)->callsign ?? null,
'datalink_authority' => $msg->datalink_authority->name,
'datalink_authority' => $msg->datalinkAuthority->name,
],
'pilot' => [
'cid' => $msg->rclMessage->vatsim_account_id ?? null,
Expand Down
16 changes: 9 additions & 7 deletions app/Http/Controllers/ClxMessagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public function transmit(RclMessage $rclMessage, ClxMessageRequest $request)
$entryRequirement = "{$request->get('entry_time_type')}{$request->get('entry_time_requirement')}";
}

$datalinkAuthority = DatalinkAuthority::find($request->get('datalink_authority_id'));

/**
* Create the message
*/
Expand All @@ -161,7 +163,7 @@ public function transmit(RclMessage $rclMessage, ClxMessageRequest $request)
'entry_time_restriction' => $entryRequirement ?? null,
'raw_entry_time_restriction' => $request->get('entry_time_requirement'),
'free_text' => $isReclearance ? '** RECLEARANCE '.now()->format('Hi').' ** '.$request->get('free_text') : $request->get('free_text'),
'datalink_authority_id' => $request->get('datalink_authority_id'),
'datalink_authority_id' => $datalinkAuthority->id,
'is_concorde' => $rclMessage->is_concorde,
]);

Expand All @@ -180,7 +182,7 @@ public function transmit(RclMessage $rclMessage, ClxMessageRequest $request)
* Create datalink messages
*/
$array = [
'CLX '.now()->format('Hi dmy').' '.$clxMessage->datalinkAuthority->id.' CLRNCE '.$clxMessage->id,
'CLX '.now()->format('Hi dmy').' '.$datalinkAuthority->id.' CLRNCE '.$clxMessage->id,
$rclMessage->callsign.' CLRD TO '.$rclMessage->destination.' VIA '.$clxMessage->entry_fix,
$clxMessage->track ? 'NAT '.$clxMessage->track->identifier : 'RANDOM ROUTE',
$clxMessage->track ? $clxMessage->track->last_routeing : $clxMessage->random_routeing,
Expand Down Expand Up @@ -214,9 +216,9 @@ public function transmit(RclMessage $rclMessage, ClxMessageRequest $request)
$clxMessage->datalink_message = $array;
$msg = '';
if ($clxMessage->track) {
$msg = "{$clxMessage->datalinkAuthority->name} clears {$rclMessage->callsign} to {$rclMessage->destination} via {$clxMessage->entry_fix}, track {$clxMessage->track->identifier}. From {$clxMessage->entry_fix} maintain Flight Level {$clxMessage->flight_level}, Mach {$clxMessage->mach}.";
$msg = "{$datalinkAuthority->name} clears {$rclMessage->callsign} to {$rclMessage->destination} via {$clxMessage->entry_fix}, track {$clxMessage->track->identifier}. From {$clxMessage->entry_fix} maintain Flight Level {$clxMessage->flight_level}, Mach {$clxMessage->mach}.";
} else {
$msg = "{$clxMessage->datalinkAuthority->name} clears {$rclMessage->callsign} to {$rclMessage->destination} via {$clxMessage->entry_fix}, random routeing {$clxMessage->random_routeing}. From {$clxMessage->entry_fix} maintain Flight Level {$clxMessage->flight_level}, Mach {$clxMessage->mach}.";
$msg = "{$datalinkAuthority->name} clears {$rclMessage->callsign} to {$rclMessage->destination} via {$clxMessage->entry_fix}, random routeing {$clxMessage->random_routeing}. From {$clxMessage->entry_fix} maintain Flight Level {$clxMessage->flight_level}, Mach {$clxMessage->mach}.";
}
// Only show crossing restriction if entry time =/= the restriction due to the bodge
if ($clxMessage->entry_time_restriction && ($clxMessage->raw_entry_time_restriction != $rclMessage->entry_time)) {
Expand Down Expand Up @@ -260,7 +262,7 @@ public function transmit(RclMessage $rclMessage, ClxMessageRequest $request)
->causedBy($clxMessage->vatsimAccount)
->performedOn($rclMessage)
->withProperties(['datalink' => $clxMessage->data_link_message])
->log('CLX Message Transmitted By '.$clxMessage->datalinkAuthority->id);
->log('CLX Message Transmitted By '.$datalinkAuthority->id);

flashAlert(type: 'success', title: null, message: 'Clearance transmitted.', toast: true, timer: true);

Expand Down Expand Up @@ -316,7 +318,7 @@ public function moveToProcessed(Request $request, RclMessage $rclMessage)
'entry_time_restriction' => null,
'raw_entry_time_restriction' => $rclMessage->entry_time,
'free_text' => "** AUTO ACKNOWLEDGE **",
'datalink_authority' => $datalinkAuthority,
'datalink_authority_id' => $datalinkAuthority->id,
'is_concorde' => $rclMessage->is_concorde,
'simple_datalink_message' => '** AUTO ACKNOWLEDGED REFER RCL REQUEST **',
'datalink_message' => ['** AUTO ACKNOWLEDGED REFER RCL REQUEST **'],
Expand Down Expand Up @@ -350,7 +352,7 @@ public function moveToProcessed(Request $request, RclMessage $rclMessage)
->causedBy($clxMessage->vatsimAccount)
->performedOn($rclMessage)
->withProperties(['datalink' => $clxMessage->data_link_message])
->log('CLX Message Transmitted By '.$clxMessage->datalinkAuthority->name);
->log('CLX Message Transmitted By '.$datalinkAuthority->name);

flashAlert(type: 'success', title: null, message: 'Clearance moved.', toast: true, timer: true);

Expand Down
13 changes: 8 additions & 5 deletions app/Http/Livewire/Controllers/CreateManualClx.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public function submit()

$pilotCid = system_user_id();

$datalinkAuthority = $this->activeDlAuthority;

$dataService = new VatsimDataService();
$flightPlan = $dataService->getVatsimAccountByCallsign($this->callsign);
if ($flightPlan) {
Expand Down Expand Up @@ -140,6 +142,7 @@ public function submit()
'tmi' => current_tmi(),
'free_text' => $this->freeText,
'vatsim_account_id' => $pilotCid,
'target_datalink_authority_id' => $datalinkAuthority->id,
'request_time' => now(),
'atc_rejected' => false,
'is_concorde' => false,
Expand Down Expand Up @@ -167,7 +170,7 @@ public function submit()
'entry_time_restriction' => null, //TODO implement
'raw_entry_time_restriction' => $rclMessage->entry_time,
'free_text' => '** RCL/CLX MANUALLY ENTERED BY ATC **',
'datalink_authority_id' => $this->activeDlAuthority->id,
'datalink_authority_id' => $datalinkAuthority->id,
'is_concorde' => $rclMessage->is_concorde,
]);
if ($rclMessage->trac) {
Expand All @@ -179,7 +182,7 @@ public function submit()
}

$array = [
'CLX '.now()->format('Hi dmy').' '.$clxMessage->datalinkAuthority->id.' CLRNCE '.$clxMessage->id,
'CLX '.now()->format('Hi dmy').' '.$datalinkAuthority->id.' CLRNCE '.$clxMessage->id,
$rclMessage->callsign.' CLRD TO '.$rclMessage->destination.' VIA '.$clxMessage->entry_fix,
$clxMessage->track ? 'NAT '.$clxMessage->track->identifier : 'RANDOM ROUTE',
$clxMessage->track ? $clxMessage->track->last_routeing : $clxMessage->random_routeing,
Expand Down Expand Up @@ -213,9 +216,9 @@ public function submit()
$clxMessage->datalink_message = $array;
$msg = '';
if ($clxMessage->track) {
$msg = "{$clxMessage->datalinkAuthority->name} clears {$rclMessage->callsign} to {$rclMessage->destination} via {$clxMessage->entry_fix}, track {$clxMessage->track->identifier}. From {$clxMessage->entry_fix} maintain Flight Level {$clxMessage->flight_level}, Mach {$clxMessage->mach}.";
$msg = "{$datalinkAuthority->name} clears {$rclMessage->callsign} to {$rclMessage->destination} via {$clxMessage->entry_fix}, track {$clxMessage->track->identifier}. From {$clxMessage->entry_fix} maintain Flight Level {$clxMessage->flight_level}, Mach {$clxMessage->mach}.";
} else {
$msg = "{$clxMessage->datalinkAuthority->name} clears {$rclMessage->callsign} to {$rclMessage->destination} via {$clxMessage->entry_fix}, random routeing {$clxMessage->random_routeing}. From {$clxMessage->entry_fix} maintain Flight Level {$clxMessage->flight_level}, Mach {$clxMessage->mach}.";
$msg = "{$datalinkAuthority->name} clears {$rclMessage->callsign} to {$rclMessage->destination} via {$clxMessage->entry_fix}, random routeing {$clxMessage->random_routeing}. From {$clxMessage->entry_fix} maintain Flight Level {$clxMessage->flight_level}, Mach {$clxMessage->mach}.";
}
// Only show crossing restriction if entry time =/= the restriction due to the bodge
if ($clxMessage->entry_time_restriction && ($clxMessage->raw_entry_time_restriction != $rclMessage->entry_time)) {
Expand Down Expand Up @@ -259,7 +262,7 @@ public function submit()
->causedBy($clxMessage->vatsimAccount)
->performedOn($rclMessage)
->withProperties(['datalink' => $clxMessage->data_link_message])
->log('CLX Message Transmitted By '.$clxMessage->datalinkAuthority->name);
->log('CLX Message Transmitted By '.$datalinkAuthority->name);

flashAlert(type: 'success', title: null, message: 'Clearance transmitted.', toast: true, timer: true);

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/RclMessageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function withValidator($validator)
/** Entry fix time requirement */
if (config('app.rcl_time_constraints_enabled') && strlen($this->entry_time) == 4) {
if (!$this->entryTimeWithinRange($this->entry_time)) {
if (config('app.rcl_auto_acknowledgement_enabled') && DatalinkAuthority::find($this->target_datalink_authority_id)->auto_acknowledge_participant) {
if (config('app.rcl_auto_acknowledgement_enabled') && DatalinkAuthority::find($this->target_datalink_authority_id)?->auto_acknowledge_participant) {
$this->cpdlcService->sendMessage(author: DatalinkAuthority::find('SYST'), recipient: $this->callsign, recipientAccount: Auth::user(), message: sprintf(RclResponsesEnum::Contact->value, strtoupper(DatalinkAuthorities::OCEN->description())), caption: RclResponsesEnum::Contact->text());
}
$lower = config('app.rcl_lower_limit') + 1;
Expand Down

0 comments on commit e9ba7a8

Please sign in to comment.