Skip to content

Commit 58748ba

Browse files
Merge pull request #217 from czqoocavatsim/dev
work
2 parents 365213f + 4d6feb6 commit 58748ba

10 files changed

+58
-23256
lines changed

.phpstorm.meta.php

-2,047
This file was deleted.

_ide_helper.php

-21,149
This file was deleted.

app/Jobs/ProcessAnnouncement.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Illuminate\Foundation\Bus\Dispatchable;
1414
use Illuminate\Queue\InteractsWithQueue;
1515
use Illuminate\Queue\SerializesModels;
16-
use RestCord\DiscordClient;
16+
use App\Services\DiscordClient;
1717

1818
class ProcessAnnouncement implements ShouldQueue
1919
{
@@ -42,7 +42,7 @@ public function __construct($announcement)
4242
public function handle()
4343
{
4444
//Discord
45-
$discord = new DiscordClient(['token' => config('services.discord.token')]);
45+
$discord = new DiscordClient();
4646

4747
//Who is it directed to
4848
switch ($this->announcement->target_group) {
@@ -52,39 +52,39 @@ public function handle()
5252
foreach ($users as $user) {
5353
$user->notify(new AnnouncementNotification($user, $this->announcement));
5454
}
55-
$discord->channel->createMessage(['channel.id' => intval(config('services.discord.web_logs')), 'content' => 'Sent '.count($users).' emails for announcement '.$this->announcement->title]);
55+
$discord->sendMessage(intval(config('services.discord.web_logs')), 'Sent '.count($users).' emails for announcement '.$this->announcement->title);
5656
break;
5757
case 'roster':
5858
// All active roster members
5959
$rosterMembers = RosterMember::where('active', 1)->get();
6060
foreach ($rosterMembers as $member) {
6161
$member->user->notify(new AnnouncementNotification($member->user, $this->announcement));
6262
}
63-
$discord->channel->createMessage(['channel.id' => intval(config('services.discord.web_logs')), 'content' => 'Sent '.count($rosterMembers).' emails to roster members for announcement '.$this->announcement->title]);
63+
$discord->sendMessage(intval(config('services.discord.web_logs')),'Sent '.count($rosterMembers).' emails to roster members for announcement '.$this->announcement->title);
6464
break;
6565
case 'staff':
6666
// All active staff members
6767
$staffMembers = StaffMember::where('user_id', '!=', 1)->get();
6868
foreach ($staffMembers as $member) {
6969
$member->user->notify(new AnnouncementNotification($member->user, $this->announcement));
7070
}
71-
$discord->channel->createMessage(['channel.id' => intval(config('services.discord.web_logs')), 'content' => 'Sent '.count($staffMembers).' emails to staff members for announcement '.$this->announcement->title]);
71+
$discord->sendMessage(intval(config('services.discord.web_logs')), 'Sent '.count($staffMembers).' emails to staff members for announcement '.$this->announcement->title);
7272
break;
7373
case 'students':
7474
// All active students
7575
$students = Student::whereCurrent(true)->get();
7676
foreach ($students as $member) {
7777
$member->user->notify(new AnnouncementNotification($member->user, $this->announcement));
7878
}
79-
$discord->channel->createMessage(['channel.id' => intval(config('services.discord.web_logs')), 'content' => 'Sent '.count($students).' emails to current students for announcement '.$this->announcement->title]);
79+
$discord->sendMessage(intval(config('services.discord.web_logs')), 'Sent '.count($students).' emails to current students for announcement '.$this->announcement->title);
8080
break;
8181
case 'students':
8282
// All active students
8383
$students = Instructor::whereCurrent(true)->get();
8484
foreach ($students as $member) {
8585
$member->user->notify(new AnnouncementNotification($member->user, $this->announcement));
8686
}
87-
$discord->channel->createMessage(['channel.id' => intval(config('services.discord.web_logs')), 'content' => 'Sent '.count($students).' emails to current instructors for announcement '.$this->announcement->title]);
87+
$discord->sendMessage(intval(config('services.discord.web_logs')), 'Sent '.count($students).' emails to current instructors for announcement '.$this->announcement->title);
8888
break;
8989
}
9090
}

app/Jobs/ProcessArticlePublishing.php

+7-34
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Illuminate\Foundation\Bus\Dispatchable;
1111
use Illuminate\Queue\InteractsWithQueue;
1212
use Illuminate\Queue\SerializesModels;
13-
use RestCord\DiscordClient;
13+
use App\Services\DiscordClient;
1414
use Throwable;
1515

1616
class ProcessArticlePublishing implements ShouldQueue
@@ -39,48 +39,27 @@ public function __construct($article)
3939
public function handle()
4040
{
4141
//Discord client
42-
$discord = new DiscordClient(['token' => config('services.discord.token')]);
42+
$discord = new DiscordClient();
4343

4444
//Send announcement
4545
try {
46-
$discord->channel->createMessage([
47-
'channel.id' => config('app.env') == 'local' ? intval(config('services.discord.web_logs')) : intval(config('services.discord.announcements')),
48-
'embed' => [
49-
'title' => $this->article->title,
50-
'description' => $this->article->summary,
51-
'color' => 0x80c9,
52-
'image' => [
53-
'url' => $this->article->image ? url('/').$this->article->image : null,
54-
],
55-
'url' => route('news.articlepublic', $this->article->slug),
56-
'author' => [
57-
'name' => $this->article->author_pretty(),
58-
],
59-
'timestamp' => date('Y-m-d H:i:s'),
60-
],
61-
]);
46+
$discord->sendMessageWithEmbed(config('app.env') == 'local' ? intval(config('services.discord.web_logs')) : intval(config('services.discord.announcements')),$this->article->title,$this->article->summary);
6247
} catch (Throwable $ex) {
6348
error_log('Webhook failed');
6449
}
6550

6651
//Send emails as appropirate
6752
switch ($this->article->email_level) {
6853
case 0:
69-
$discord->channel->createMessage([
70-
'channel.id' => intval(config('services.discord.web_logs')),
71-
'content' => 'Sent no emails for article '.$this->article->title,
72-
]);
54+
$discord->sendMessage(intval(config('services.discord.web_logs')),'Sent no emails for article '.$this->article->title);
7355
break;
7456
case 1:
7557
//Send to controllers
7658
$roster = RosterMember::where('certification', '!=', 'not_certified')->get();
7759
foreach ($roster as $member) {
7860
$member->user->notify(new NewsNotification($member->user, $this->article));
7961
}
80-
$discord->channel->createMessage([
81-
'channel.id' => intval(config('services.discord.web_logs')),
82-
'content' => 'Sent '.count($roster).' emails to controllers for article '.$this->article->title,
83-
]);
62+
$discord->sendMessage(intval(config('services.discord.web_logs')), 'Sent '.count($roster).' emails to controllers for article '.$this->article->title);
8463
break;
8564
case 2:
8665
//Send to subscribed users
@@ -94,21 +73,15 @@ public function handle()
9473
foreach ($users as $user) {
9574
$user->notify(new NewsNotification($user, $this->article));
9675
}
97-
$discord->channel->createMessage([
98-
'channel.id' => intval(config('services.discord.web_logs')),
99-
'content' => 'Sent '.count($users).' emails to subscribed users for article '.$this->article->title,
100-
]);
76+
$discord->sendMessage(intval(config('services.discord.web_logs')), 'Sent '.count($users).' emails to subscribed users for article '.$this->article->title);
10177
break;
10278
case 3:
10379
//Send to all
10480
$users = User::all();
10581
foreach ($users as $user) {
10682
$user->notify(new NewsNotification($user, $this->article));
10783
}
108-
$discord->channel->createMessage([
109-
'channel.id' => intval(config('services.discord.web_logs')),
110-
'content' => 'Sent '.count($users).' emails to all users for article '.$this->article->title,
111-
]);
84+
$discord->sendMessage(intval(config('services.discord.web_logs')), 'Sent '.count($users).' emails to all users for article '.$this->article->title);
11285
}
11386
}
11487
}

app/Jobs/ProcessDataExport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function handle()
4040
$userArray = $user->toArray();
4141
$discord = null;
4242
if ($user->hasDiscord()) {
43-
$discord = $user->getDiscordUser();
43+
$discord = $user->discord_user_id;
4444
}
4545
array_push($userArray, $discord);
4646
$json = json_encode($userArray, JSON_PRETTY_PRINT);

app/Jobs/ProcessSoloCertExpiryWarnings.php

+3-13
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Illuminate\Queue\InteractsWithQueue;
1515
use Illuminate\Queue\SerializesModels;
1616
use Illuminate\Support\Facades\Notification;
17-
use RestCord\DiscordClient;
17+
use App\Services\DiscordClient;
1818

1919
class ProcessSoloCertExpiryWarnings implements ShouldQueue
2020
{
@@ -48,18 +48,8 @@ public function handle()
4848
//If cert is about to expire
4949
if (Carbon::now()->diffInDays($cert->expires) <= 2) {
5050
//Discord notification in instructors channel
51-
$discord = new DiscordClient(['token' => config('services.discord.token')]);
52-
$discord->channel->createMessage([
53-
'channel.id' => intval(config('services.discord.instructors')),
54-
'content' => '',
55-
'embed' => [
56-
'title' => 'Solo certification for '.$cert->rosterMember->user->fullName('FLC').' is about to expire.',
57-
'url' => route('training.admin.solocertifications'),
58-
'timestamp' => Carbon::now(),
59-
'color' => hexdec('2196f3'),
60-
'description' => 'Expires on '.$cert->expires->toDayDateTimeString().'.',
61-
],
62-
]);
51+
$discord = new DiscordClient();
52+
$discord->sendMessageWithEmbed(intval(config('services.discord.instructors')), 'Solo certification for '.$cert->rosterMember->user->fullName('FLC').' is about to expire.','Expires on '.$cert->expires->toDayDateTimeString().'.');
6353

6454
//Notify their instructor
6555
if ($cert->rosterMember->user->studentProfile && $cert->rosterMember->user->studentProfile->instructor()) {

app/Jobs/UpdateDiscordUserRoles.php

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Illuminate\Foundation\Bus\Dispatchable;
99
use Illuminate\Queue\InteractsWithQueue;
1010
use Illuminate\Queue\SerializesModels;
11-
use Illuminate\Support\Facades\Log;
1211
use RestCord\DiscordClient;
1312

1413
class UpdateDiscordUserRoles implements ShouldQueue

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"laravel/framework": "^9.0",
2121
"laravel/tinker": "^2.0",
2222
"laravel/ui": "^4.0",
23-
"laravelcollective/html": "^6.4",
2423
"lasserafn/php-initial-avatar-generator": "^4.0",
2524
"lasserafn/php-initials": "^3.1",
2625
"league/flysystem-aws-s3-v3": "^3.1",

config/app.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
MisterPhilip\MaintenanceMode\MaintenanceCommandServiceProvider::class,
166166
NotificationChannels\Discord\DiscordServiceProvider::class,
167167
Bugsnag\BugsnagLaravel\BugsnagServiceProvider::class,
168-
Collective\Html\HtmlServiceProvider::class,
168+
Spatie\Html\HtmlServiceProvider::class,
169169

170170
/*
171171
* Application Service Providers...
@@ -225,11 +225,12 @@
225225
'URL' => Illuminate\Support\Facades\URL::class,
226226
'Validator' => Illuminate\Support\Facades\Validator::class,
227227
'View' => Illuminate\Support\Facades\View::class,
228-
'Form' => Collective\Html\FormFacade::class,
229228
'GoogleCalendar' => Spatie\GoogleCalendar\GoogleCalendarFacade::class,
230229
'PDF' => Barryvdh\DomPDF\Facade::class,
231230
'Calendar' => \MaddHatter\LaravelFullcalendar\Facades\Calendar::class,
232-
'Html' => Collective\Html\HtmlFacade::class,
231+
'Form' => Spatie\Html\Facades\Form::class,
232+
'Html' => Spatie\Html\Facades\Html::class,
233+
233234

234235
],
235236

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('failed_jobs', function (Blueprint $table) {
17+
$table->id();
18+
$table->string('uuid')->unique();
19+
$table->text('connection');
20+
$table->text('queue');
21+
$table->longText('payload');
22+
$table->longText('exception');
23+
$table->timestamp('failed_at')->useCurrent();
24+
});
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*
30+
* @return void
31+
*/
32+
public function down()
33+
{
34+
Schema::dropIfExists('failed_jobs');
35+
}
36+
};

0 commit comments

Comments
 (0)