Skip to content

Commit

Permalink
Merge pull request #285 from czqoocavatsim/JoshuaNeedsCoffee
Browse files Browse the repository at this point in the history
Fix Application Error
  • Loading branch information
JoshuaMicallefYBSU authored Aug 15, 2024
2 parents e3d5875 + 9adcdd4 commit ee1cfe8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Training/ApplicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function apply(Request $request)
//Check Shanwick roster
$shanwickRoster = json_decode(Cache::remember('shanwickroster', 86400, function () {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.vatsim.uk/api/validations?position=EGGX');
curl_setopt($ch, CURLOPT_URL, 'https://www.vatsim.uk/api/validations?position=EGGX_FSS');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Training/InstructingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function addStudent(Request $request)
Session::flash('info', 'Unable to add Discord permissions automatically.');
}
} catch (\Exception $e) {
Session::flash('info', 'Unable to remove Discord permissions automatically.');

}

//Give Awaiting Exam status label
Expand Down Expand Up @@ -401,7 +401,7 @@ public function removeStudent($cid)
$student->user->removeRole('Student');

//Discord Updates
if (!$student->user->hasDiscord()) {
if ($student->user->hasDiscord() && $student->user->member_of_czqo) {
//Get Discord client
$discord = new DiscordClient();

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Training/SessionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function createTrainingSession(Request $request)
$discord->sendEmbedInTrainingThread($session->student->user->fullName('FLC'), 'Training Session Booked',
'Hello, '. $session->student->user->fullName('F').'!
A training session has been created for you at '.Carbon::parse($request->get('scheduled_time'))->format('l, jS F H:i\z').'.
A training session has been created for you on <t:'.Carbon::parse($request->get('scheduled_time'))->timestamp.':F>.
Please reach out to your instructor in this training thread if you have any questions.');

Expand Down Expand Up @@ -139,7 +139,7 @@ public function editTrainingSessionTime(Request $request, $session_id)
$discord->sendEmbedInTrainingThread($session->student->user->fullName('FLC'), 'Training Session Time Changed',
'Hello, '. $session->student->user->fullName('F').'!
A training session time has been updated. The new time is now '.Carbon::parse($request->get('new_time'))->format('l, jS F H:i\z').'.
A training session time has been updated. The new time is now <t:'.Carbon::parse($request->get('new_time'))->timestamp.':F>
Please reach out to your instructor in this training thread if you have any questions.');

Expand Down
19 changes: 10 additions & 9 deletions app/Services/DiscordClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use GuzzleHttp\Client;
use App\Jobs\ProcessDiscordRoles;
use GuzzleHttp\Exception\ClientException;
use Carbon\Carbon;

class DiscordClient
{
Expand Down Expand Up @@ -127,14 +128,6 @@ public function closeTrainingThread($name, $status)
foreach ($threads_data['threads'] as $thread) {
if ($thread['name'] == $name) {

// Lock and Archive the Thread
$data = $this->client->patch('channels/'.$thread['id'], [
'json' => [
'locked' => true,
'archived' => true,
]
]);

if($status == "certify"){
$this->sendMessageWithEmbed($thread['id'], 'Oceanic Training Completed!',
'Congratulations, you have now been certified on Gander & Shanwick Oceanic!
Expand All @@ -146,10 +139,18 @@ public function closeTrainingThread($name, $status)
Enjoy controlling Gander & Shanwick OCA!');
} elseif($status == "cancel") {
$this->sendMessageWithEmbed($thread['id'], 'Oceanic Training Cancelled',
'Your training request with Gander Oceanic has been terminated.
'Your training request with Gander Oceanic has been terminated on <t:'.Carbon::now()->timestamp.':F>
If you would like to begin training again, please re-apply via the Gander Website.');
}

// Lock and Archive the Thread
$data = $this->client->patch('channels/'.$thread['id'], [
'json' => [
'locked' => true,
'archived' => true,
]
]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
</ul>
<h5 class="blue-text">Actions</h5>
<ul class="list-unstyled mt-2">
@if(Auth::user()->id == "1342084" || Auth::user()->hasRole('Instructor'))
@can('edit students')
<div class="list-group z-depth-1">
<a data-target="#deleteStudentModal" data-toggle="modal" class="list-group-item list-group-item-action red-text"><i class="fas fa-dumpster-fire mr-3"></i>Remove User as Student</a>
</div>
@endif
@endcan
@if($student->user->rosterProfile->certification == "training")
<div class="list-group z-depth-1">
<a data-target="#certifyStudentModal" data-toggle="modal" class="list-group-item list-group-item-action green-text"><i class="fas fa-check mr-3"></i>Certify Controller</a>
Expand Down

0 comments on commit ee1cfe8

Please sign in to comment.