Skip to content

Commit

Permalink
Merge pull request #249 from czqoocavatsim/development
Browse files Browse the repository at this point in the history
Work
  • Loading branch information
mufassilyasir authored Feb 11, 2024
2 parents 71beb5e + 6bc9447 commit 3546cfb
Show file tree
Hide file tree
Showing 48 changed files with 1,631 additions and 1,071 deletions.
58 changes: 58 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
APP_NAME="Gander Oceanic OCA"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://ganderoceanic.test

LOG_CHANNEL=discord
LOG_DISCORD_WEBHOOK_URL=

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=
QUEUE_CONNECTION=sync

#CTP Home page
CTP_HOME_PAGE=false

#If you want to send mail
MAIL_DRIVER=smtp
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=

#Channel IDs for Discord channels if you want them to work
DISCORD_WEB_LOGS=753086414811562014
DISCORD_GUILD_LOGS=482860026831175690
DISCORD_ANNOUNCEMENTS=488265136696459292
DISCORD_ENDORSEMENTS=538938024470511648
DISCORD_MARKETING=557500419614703617
DISCORD_STAFF=536497946359758863
DISCORD_INSTRUCTORS=782927909974442015

#Discord OAuth keys for linking/server joining
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
DISCORD_BOT_TOKEN=
DISCORD_REDIRECT_URI=https://ganderoceanic.ca/my/discord/link/callback
DISCORD_REDIRECT_URI_JOIN=https://ganderoceanic.ca/my/discord/server/join/callback
DISCORD_GUILD_ID=479250337048297483

#VATSIM connect
CONNECT_CLIENT_ID=
CONNECT_SECRET=
CONNECT_REDIRECT_URI="http://ganderoceanic.test/auth/connect/validate"

#Spaces
DIGITALOCEAN_SPACES_KEY=
DIGITALOCEAN_SPACES_SECRET=
DIGITALOCEAN_SPACES_ENDPOINT=
DIGITALOCEAN_SPACES_REGION=
DIGITALOCEAN_SPACES_BUCKET=

QUOTES_API_TOKEN=

7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ app/storage/

# Laravel 5 & Lumen specific
public/storage
public/assets/files/avatars
public/assets/user_uploads
public/hot
storage/*.key
storage/debugbar
Expand All @@ -22,12 +24,7 @@ Homestead.json
app/Http/Controllers/vendor/skymeyer/vatsimphp/app/logs/pilots.log

*.zip


.vscode/

.idea/

.DS_Store

training.yaml
60 changes: 30 additions & 30 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,38 @@ protected function schedule(Schedule $schedule)
$schedule->job(new ProcessRosterInactivity())->cron('00 00 01 JAN,APR,JUL,OCT *');

//CRONS FOR INACTIVITY EMAILS 2 weeks
$schedule->call(function () {
//Loop through controllers
$count = 0;
foreach (RosterMember::all() as $rosterMember) {
//Do they meet the requirements?
if (!$rosterMember->meetsActivityRequirement()) {
$count++;
$rosterMember->user->notify(new TwoWeekInactivityReminder($rosterMember, 'n/a'));
}
}

//Tell Discord all about it
$discord = new DiscordClient();
$discord->sendMessage(753086414811562014, 'Sent '.$count.' two-week warning inactivity emails');
})->cron('00 00 16 MAR,JUN,SEP,DEC *'); // 2 weeks before end of quarter
// $schedule->call(function () {
// //Loop through controllers
// $count = 0;
// foreach (RosterMember::all() as $rosterMember) {
// //Do they meet the requirements?
// if (!$rosterMember->meetsActivityRequirement()) {
// $count++;
// $rosterMember->user->notify(new TwoWeekInactivityReminder($rosterMember, 'n/a'));
// }
// }

// //Tell Discord all about it
// $discord = new DiscordClient();
// $discord->sendMessage(753086414811562014, 'Sent '.$count.' two-week warning inactivity emails');
// })->cron('00 00 16 MAR,JUN,SEP,DEC *'); // 2 weeks before end of quarter

// 1 week
$schedule->call(function () {
//Loop through controllers
$count = 0;
foreach (RosterMember::all() as $rosterMember) {
//Do they meet the requirements?
if (!$rosterMember->meetsActivityRequirement()) {
$count++;
$rosterMember->user->notify(new OneWeekInactivityReminder($rosterMember, 'n/a'));
}
}
//Tell Discord all about it
$discord = new DiscordClient();
$discord->sendMessage(753086414811562014, 'Sent '.$count.' one-week warning inactivity emails');
})->cron('00 00 23 MAR,JUN,SEP,DEC *'); // 1 week before end of quarter*/
// $schedule->call(function () {
// //Loop through controllers
// $count = 0;
// foreach (RosterMember::all() as $rosterMember) {
// //Do they meet the requirements?
// if (!$rosterMember->meetsActivityRequirement()) {
// $count++;
// $rosterMember->user->notify(new OneWeekInactivityReminder($rosterMember, 'n/a'));
// }
// }

// //Tell Discord all about it
// $discord = new DiscordClient();
// $discord->sendMessage(753086414811562014, 'Sent '.$count.' one-week warning inactivity emails');
// })->cron('00 00 23 MAR,JUN,SEP,DEC *'); // 1 week before end of quarter*/

/// Monthly leaderboard wipe
$schedule->call(function () {
Expand Down
40 changes: 19 additions & 21 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Models\Users\User;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\Models\Users\UserPreferences;
Expand Down Expand Up @@ -76,14 +75,13 @@ public function validateConnectLogin(Request $request)
session()->put('token', json_decode((string) $response->getBody(), true));

try {
$response = (new \GuzzleHttp\Client())->get(config('connect.endpoint').'/api/user', [
$response = (new Client())->get(config('connect.endpoint').'/api/user', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer '.session()->get('token.access_token'),
],
]);
} catch (ClientException $e) {
dd($e);
return redirect()->route('index')->with('error-modal', $e->getMessage());
}
$response = json_decode($response->getBody());
Expand All @@ -93,7 +91,7 @@ public function validateConnectLogin(Request $request)
if (!isset($response->data->vatsim->rating)) {
return redirect()->route('index')->with('error-modal', 'We cannot create an account without VATSIM details.');
}
User::updateOrCreate(['id' => $response->data->cid], [
$user = User::updateOrCreate(['id' => $response->data->cid], [
'email' => isset($response->data->personal->email) ? $response->data->personal->email : '[email protected]',
'fname' => isset($response->data->personal->name_first) ? utf8_decode($response->data->personal->name_first) : $response->data->cid,
'lname' => isset($response->data->personal->name_last) ? $response->data->personal->name_last : $response->data->cid,
Expand All @@ -109,28 +107,28 @@ public function validateConnectLogin(Request $request)
'display_fname' => isset($response->data->personal->name_first) ? utf8_decode($response->data->personal->name_first) : $response->data->cid,
'used_connect' => true,
]);
$user = User::find($response->data->cid);

if ($user->wasRecentlyCreated) {
UserPreferences::create([
'user_id' => $response->data->cid,
'ui_mode' => 'light'
]);
UserNotificationPreferences::create([
'user_id' => $response->data->cid,
]);
UserPrivacyPreferences::create([
'user_id' => $response->data->cid
]);
}

$user->genInitialAvatar();

if (!isset($response->data->personal->name_first)) {
$user->display_cid_only = true;
}

$user->save();
Auth::login($user, true);
if (!UserPreferences::where('user_id', $user->id)->first()) {
$prefs = new UserPreferences();
$prefs->user_id = $user->id;
$prefs->ui_mode = 'light';
$prefs->save();
}
if (!UserPrivacyPreferences::where('user_id', $user->id)->first()) {
$priv = new UserPrivacyPreferences();
$priv->user_id = $user->id;
$priv->save();
}
if (!UserNotificationPreferences::where('user_id', $user->id)->first()) {
$notif = new UserNotificationPreferences();
$notif->user_id = $user->id;
$notif->save();
}

return redirect()->route('my.index')->with('success', "Welcome back, {$user->fullName('F')}!");
}
Expand Down
27 changes: 13 additions & 14 deletions app/Http/Controllers/Community/MyCzqoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Http\Request;
use App\Services\DiscordClient;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\Models\Users\UserPreferences;
use App\Notifications\WelcomeNewUser;
use Illuminate\Support\Facades\Cache;
Expand All @@ -30,7 +29,7 @@ class MyCzqoController extends Controller
public function acceptPrivacyPolicy(Request $request)
{
//Get the user
$user = Auth::user();
$user = auth()->user();

//If they're already initiated...
if ($user->init) {
Expand Down Expand Up @@ -68,7 +67,7 @@ public function acceptPrivacyPolicy(Request $request)
public function denyPrivacyPolicy()
{
//Get the user
$user = Auth::user();
$user = auth()->user();

//If they're already initiated...
if ($user->init) {
Expand All @@ -77,7 +76,7 @@ public function denyPrivacyPolicy()
}

//Well lets log them out
Auth::logout($user);
auth()->logout($user);

//Delete their privacy, notifs, prefs
$notifPrefs = UserNotificationPreferences::where('user_id', $user->id)->first();
Expand Down Expand Up @@ -108,7 +107,7 @@ public function saveBiography(Request $request)
]);

//Get user
$user = Auth::user();
$user = auth()->user();

//Get input
$input = $request->get('bio');
Expand Down Expand Up @@ -147,7 +146,7 @@ public function changeAvatarCustomImage(Request $request)
], $messages);

//Get user
$user = Auth::user();
$user = auth()->user();

//Put it onto disk
$path = Storage::put('user_uploads/'.$user->id.'/avatars', $request->file('file'));
Expand All @@ -169,7 +168,7 @@ public function changeAvatarCustomImage(Request $request)
public function changeAvatarDiscord()
{
//Get user
$user = Auth::user();
$user = auth()->user();

//They need Discord don't they
if (!$user->hasDiscord()) {
Expand All @@ -195,7 +194,7 @@ public function changeAvatarDiscord()
public function changeAvatarInitials()
{
//Get user
$user = Auth::user();
$user = auth()->user();

//Change mode and save
$user->avatar_mode = 0;
Expand All @@ -221,7 +220,7 @@ public function changeDisplayName(Request $request)
]);

//Get user
$user = Auth::user();
$user = auth()->user();

//No swear words... give them the new name!
$user->display_fname = $request->get('display_fname');
Expand All @@ -246,7 +245,7 @@ public function changeDisplayName(Request $request)
}

//Redirect
return redirect()->back()->with('success', 'Display name saved! If your avatar is set to default, it may take a while for the initials to update.');
return back()->with('success', 'Display name saved! If your avatar is set to default, it may take a while for the initials to update.');
}

/**
Expand All @@ -257,7 +256,7 @@ public function changeDisplayName(Request $request)
public function preferences()
{
//Get preferences
$preferences = Auth::user()->preferences;
$preferences = auth()->user()->preferences;

//return
return view('my.preferences', compact('preferences'));
Expand Down Expand Up @@ -286,13 +285,13 @@ public function preferencesPost(Request $request)
//Get user's preferences object
switch ($request->get('table')) {
case 'main':
$preferences = Auth::user()->preferences;
$preferences = auth()->user()->preferences;
break;
case 'notifications':
$preferences = UserNotificationPreferences::where('user_id', Auth::id())->first();
$preferences = UserNotificationPreferences::where('user_id', auth()->id())->first();
break;
case 'privacy':
$preferences = UserPrivacyPreferences::where('user_id', Auth::id())->first();
$preferences = UserPrivacyPreferences::where('user_id', auth()->id())->first();
}

//Change variable
Expand Down
Loading

0 comments on commit 3546cfb

Please sign in to comment.