From fa88cf4ea6eabef006e48ffea7443e3e4f7c654d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 25 Sep 2022 03:00:00 -0600 Subject: [PATCH 1/2] Update v1.1 api --- .../Controllers/Api/ApiV1Dot1Controller.php | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Dot1Controller.php b/app/Http/Controllers/Api/ApiV1Dot1Controller.php index 7dff38cbc..757846e2d 100644 --- a/app/Http/Controllers/Api/ApiV1Dot1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Dot1Controller.php @@ -314,15 +314,19 @@ class ApiV1Dot1Controller extends Controller $user = $request->user(); abort_if(!$user, 403); abort_if($user->status != null, 403); + $from = config('mail.from.address'); $emailVerifications = EmailVerification::whereUserId($user->id) ->orderByDesc('id') ->where('created_at', '>', now()->subDays(14)) ->limit(10) ->get() - ->map(function($mail) { + ->map(function($mail) use($user, $from) { return [ 'type' => 'Email Verification', + 'subject' => 'Confirm Email', + 'to_address' => $user->email, + 'from_address' => $from, 'created_at' => $mail->created_at->format('c') ]; }) @@ -334,9 +338,12 @@ class ApiV1Dot1Controller extends Controller ->orderByDesc('created_at') ->limit(10) ->get() - ->map(function($mail) { + ->map(function($mail) use($user, $from) { return [ 'type' => 'Password Reset', + 'subject' => 'Reset Password Notification', + 'to_address' => $user->email, + 'from_address' => $from, 'created_at' => now()->parse($mail->created_at)->format('c') ]; }) @@ -348,19 +355,23 @@ class ApiV1Dot1Controller extends Controller ->orderByDesc('created_at') ->limit(10) ->get() - ->map(function($mail) { + ->map(function($mail) use($user, $from) { return [ 'type' => 'Password Change', - 'created_at' => $mail->created_at + 'subject' => 'Password Change', + 'to_address' => $user->email, + 'from_address' => $from, + 'created_at' => now()->parse($mail->created_at)->format('c') ]; }) ->toArray(); - $res = [ - 'email_verifications' => $emailVerifications, - 'password_resets' => $passwordResets, - 'password_changes' => $passwordChanges - ]; + $res = collect([]) + ->merge($emailVerifications) + ->merge($passwordResets) + ->merge($passwordChanges) + ->sortByDesc('created_at') + ->values(); return $this->json($res); } From 12f9539054e4d716e3712f20d8765699776b5881 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 25 Sep 2022 03:28:43 -0600 Subject: [PATCH 2/2] Update v1.1 api --- app/Http/Controllers/Api/ApiV1Dot1Controller.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Dot1Controller.php b/app/Http/Controllers/Api/ApiV1Dot1Controller.php index 757846e2d..49c732549 100644 --- a/app/Http/Controllers/Api/ApiV1Dot1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Dot1Controller.php @@ -327,7 +327,7 @@ class ApiV1Dot1Controller extends Controller 'subject' => 'Confirm Email', 'to_address' => $user->email, 'from_address' => $from, - 'created_at' => $mail->created_at->format('c') + 'created_at' => str_replace('@', 'at', $mail->created_at->format('M j, Y @ g:i:s A')) ]; }) ->toArray(); @@ -344,7 +344,7 @@ class ApiV1Dot1Controller extends Controller 'subject' => 'Reset Password Notification', 'to_address' => $user->email, 'from_address' => $from, - 'created_at' => now()->parse($mail->created_at)->format('c') + 'created_at' => str_replace('@', 'at', now()->parse($mail->created_at)->format('M j, Y @ g:i:s A')) ]; }) ->toArray(); @@ -361,7 +361,7 @@ class ApiV1Dot1Controller extends Controller 'subject' => 'Password Change', 'to_address' => $user->email, 'from_address' => $from, - 'created_at' => now()->parse($mail->created_at)->format('c') + 'created_at' => str_replace('@', 'at', now()->parse($mail->created_at)->format('M j, Y @ g:i:s A')) ]; }) ->toArray();