Skip to content

Commit

Permalink
Merge pull request #320 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
SessionLog Error Intro
  • Loading branch information
JoshuaMicallefYBSU authored Aug 20, 2024
2 parents 8552575 + 1ba6126 commit 4d035ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
30 changes: 20 additions & 10 deletions app/Jobs/ProcessSessionLogging.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,18 @@ public function handle()
}

if($session->discord_id == null){
$discord = new DiscordClient();
$discord_id = $discord->ControllerConnection($controller->callsign, $name);
try{
$discord = new DiscordClient();
$discord_id = $discord->ControllerConnection($controller->callsign, $name);

$session->discord_id = $discord_id;
$session->save();
} catch (\Exception $e) {
$discord = new DiscordClient();
$discord->sendMessageWithEmbed(env('DISCORD_WEB_LOGS'), 'Discord Controller Connect Error', $e->getMessage());
}
}

$session->discord_id = $discord_id;
$session->save();

array_push($positionsFound, $controller->callsign);
}
}
Expand All @@ -98,13 +103,18 @@ public function handle()
}

if($log->discord_id !== null){
$discord = new DiscordClient();
$data = $discord->ControllerDisconnect($log->discord_id, $log->callsign, $name, $log->session_start, $log->duration);

$log->discord_id = null;
$log->save;
try{
$discord = new DiscordClient();
$data = $discord->ControllerDisconnect($log->discord_id, $log->callsign, $name, $log->session_start, $log->duration);
} catch (\Exception $e) {
$discord = new DiscordClient();
$discord->sendMessageWithEmbed(env('DISCORD_WEB_LOGS'), 'Discord Controller Disconnect Error', $e->getMessage());
}
}

$log->discord_id = null;
$log->save;

//If there is an associated roster member, give them the hours
if ($rosterMember = $log->rosterMember) {
if (($rosterMember->certification == 'certified' || $rosterMember->certification == 'training') && $rosterMember->active) {
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Network/SessionLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SessionLog extends Model

public function user()
{
return $this->belongsTo(User::class);
return $this->belongsTo(User::class, 'cid', 'id');
}

public function position()
Expand Down
8 changes: 4 additions & 4 deletions app/Services/DiscordClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public function ControllerConnection($callsign, $name)
"tts" => false,
"embeds" => [
[
'title' => $callsign.' Just Connected!',
'description' => 'A new controller has just connected to the network!
'title' => $callsign.' is currently online!',
'description' => 'There is currently ATC being provided over the Ocean!
Controller Name: '.$name.'
Online from: <t:'.Carbon::now()->timestamp.':t>',
**Controller:** '.$name.'
**Online from:** <t:'.Carbon::now()->timestamp.':t>',
'color' => hexdec('6EC40C'),
]
]
Expand Down

0 comments on commit 4d035ba

Please sign in to comment.