Skip to content

Commit 9d66fa2

Browse files
committed
Merge branch 'release/v1.2.0' into main
2 parents 8e6455e + a2a569c commit 9d66fa2

File tree

19 files changed

+429
-161
lines changed

19 files changed

+429
-161
lines changed

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@
44
All notable changes to this project will be documented in this file.
55
<!--- END HEADER -->
66

7+
## [1.2.0](https://github.com/itinerare/Alcyone/compare/v1.1.1...v1.2.0) (2023-11-12)
8+
9+
### Features
10+
11+
12+
##### Reports
13+
14+
* Add opt-in email notifications for new reports, tests ([81d28e](https://github.com/itinerare/Alcyone/commit/81d28eac8fece0b2e582ca81287a8ab039342580))
15+
16+
##### Users
17+
18+
* Add admin notification preference, tests ([3ce088](https://github.com/itinerare/Alcyone/commit/3ce088750f4754479c3b13c81e02a08715353cc8))
19+
20+
### Bug Fixes
21+
22+
23+
##### Admin
24+
25+
* Fix rank page verbiage ([48f972](https://github.com/itinerare/Alcyone/commit/48f97269cbb6ac0a8e91e7338b111d4a7b8972ad))
26+
27+
##### Tests
28+
29+
* Tweak report notif test conditions ([f4a793](https://github.com/itinerare/Alcyone/commit/f4a793aa73d7e22fdfb8974896d9f85798dbd8ca))
30+
31+
32+
---
33+
734
## [1.1.1](https://github.com/itinerare/Alcyone/compare/v1.1.0...v1.1.1) (2023-11-05)
835

936
### Bug Fixes

app/Http/Controllers/AccountController.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,31 @@ public function postEmail(Request $request, UserService $service) {
110110
return redirect()->back();
111111
}
112112

113+
/**
114+
* Changes the user's admin notification setting.
115+
*
116+
* @return \Illuminate\Http\RedirectResponse
117+
*/
118+
public function postAdminNotifs(Request $request) {
119+
$request->validate([
120+
'receive_admin_notifs' => 'required|boolean',
121+
]);
122+
123+
if (!Auth::user()->isMod) {
124+
Auth::user()->update([
125+
'receive_admin_notifs' => 0,
126+
]);
127+
abort(404);
128+
}
129+
130+
Auth::user()->update([
131+
'receive_admin_notifs' => $request->get('receive_admin_notifs'),
132+
]);
133+
flash('Admin notification preference updated successfully.')->success();
134+
135+
return redirect()->back();
136+
}
137+
113138
/**
114139
* Enables the user's two factor auth.
115140
*

app/Mail/ReportSubmitted.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace App\Mail;
4+
5+
use App\Models\Report\Report;
6+
use Illuminate\Bus\Queueable;
7+
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
10+
use Illuminate\Queue\SerializesModels;
11+
12+
class ReportSubmitted extends Mailable {
13+
use Queueable, SerializesModels;
14+
15+
/**
16+
* The report instance.
17+
*
18+
* @var \App\Models\Report\Report
19+
*/
20+
public $report;
21+
22+
/**
23+
* The image upload instance.
24+
*
25+
* @var \App\Models\ImageUpload
26+
*/
27+
public $image;
28+
29+
/**
30+
* Create a new message instance.
31+
*/
32+
public function __construct(Report $report) {
33+
$this->afterCommit();
34+
$this->report = $report;
35+
$this->image = $report->image;
36+
}
37+
38+
/**
39+
* Get the message envelope.
40+
*/
41+
public function envelope(): Envelope {
42+
return new Envelope(
43+
subject: 'New Content Report Submitted',
44+
);
45+
}
46+
47+
/**
48+
* Get the message content definition.
49+
*/
50+
public function content(): Content {
51+
return new Content(
52+
markdown: 'mail.report-submitted',
53+
);
54+
}
55+
56+
/**
57+
* Get the attachments for the message.
58+
*
59+
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
60+
*/
61+
public function attachments(): array {
62+
return [];
63+
}
64+
}

app/Models/User/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class User extends Authenticatable implements MustVerifyEmail {
2020
*/
2121
protected $fillable = [
2222
'name', 'email', 'password', 'rank_id', 'theme',
23-
'is_banned', 'ban_reason', 'banned_at',
23+
'is_banned', 'ban_reason', 'banned_at', 'receive_admin_notifs',
2424
];
2525

2626
/**

app/Services/ReportManager.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
use App\Mail\ReportAccepted;
66
use App\Mail\ReportCancelled;
7+
use App\Mail\ReportSubmitted;
78
use App\Models\ImageUpload;
89
use App\Models\Report\Report;
910
use App\Models\Report\Reporter;
11+
use App\Models\User\User;
1012
use Carbon\Carbon;
1113
use Illuminate\Support\Facades\DB;
1214
use Illuminate\Support\Facades\Mail;
@@ -71,6 +73,13 @@ public function createReport($data) {
7173
$report->key = $report->id.$report->key;
7274
$report->save();
7375

76+
// Send an email notification to relevant users
77+
foreach (User::where('receive_admin_notifs', 1)->get() as $user) {
78+
if ($user->isMod) {
79+
Mail::to($user->email)->send(new ReportSubmitted($report));
80+
}
81+
}
82+
7483
return $this->commitReturn($report);
7584
} catch (\Exception $e) {
7685
$this->setError('error', $e->getMessage());

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@
8888
},
8989
"minimum-stability": "stable",
9090
"prefer-stable": true,
91-
"version": "1.1.1"
91+
"version": "1.2.0"
9292
}

0 commit comments

Comments
 (0)