From 128bdf500abce07b483b57684b8320fec8370d4c Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 25 Aug 2025 12:02:23 -0700 Subject: [PATCH 1/3] sends an email for to locale and cc locale --- app/Http/Controllers/Account/AcceptanceController.php | 6 +++--- app/Listeners/CheckoutableListener.php | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php index 73e26422f60b..a029e97df123 100644 --- a/app/Http/Controllers/Account/AcceptanceController.php +++ b/app/Http/Controllers/Account/AcceptanceController.php @@ -248,15 +248,15 @@ public function store(Request $request, $id) : RedirectResponse // Add the attachment for the signing user into the $data array $data['file'] = $pdf_filename; - + $locale = $assigned_user->locale; try { - $assigned_user->notify(new AcceptanceAssetAcceptedToUserNotification($data)); + $assigned_user->notify((new AcceptanceAssetAcceptedToUserNotification($data))->locale($locale)); } catch (\Exception $e) { Log::warning($e); } } try { - $acceptance->notify(new AcceptanceAssetAcceptedNotification($data)); + $acceptance->notify((new AcceptanceAssetAcceptedToUserNotification($data))->locale(Setting::getSettings()->locale)); } catch (\Exception $e) { Log::warning($e); } diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index 7e289b19e657..9674bd63a3ed 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -96,7 +96,8 @@ public function onCheckedOut($event) if (!empty($to)) { try { - Mail::to(array_flatten($to))->cc(array_flatten($cc))->send($mailable); + Mail::to(array_flatten($to))->send($mailable->locale($notifiable->locale)); + Mail::to(array_flatten($cc))->send($mailable->locale(Setting::getSettings()->locale)); Log::info('Checkout Mail sent to checkout target'); } catch (ClientException $e) { Log::debug("Exception caught during checkout email: " . $e->getMessage()); @@ -180,7 +181,8 @@ public function onCheckedIn($event) try { if (!empty($to)) { - Mail::to(array_flatten($to))->cc(array_flatten($cc))->send($mailable); + Mail::to(array_flatten($to))->send($mailable->locale($notifiable->locale)); + Mail::to(array_flatten($cc))->send($mailable->locale(Setting::getSettings()->locale)); Log::info('Checkin Mail sent to CC addresses'); } } catch (ClientException $e) { From f518af6d61554947e2251b48dbff1040bcaad8f4 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 27 Aug 2025 13:09:05 -0700 Subject: [PATCH 2/3] fix class name --- app/Http/Controllers/Account/AcceptanceController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php index a029e97df123..f79ec1842f71 100644 --- a/app/Http/Controllers/Account/AcceptanceController.php +++ b/app/Http/Controllers/Account/AcceptanceController.php @@ -256,7 +256,7 @@ public function store(Request $request, $id) : RedirectResponse } } try { - $acceptance->notify((new AcceptanceAssetAcceptedToUserNotification($data))->locale(Setting::getSettings()->locale)); + $acceptance->notify((new AcceptanceAssetAcceptedNotification($data))->locale(Setting::getSettings()->locale)); } catch (\Exception $e) { Log::warning($e); } From f2ec7f29753fda65430ab122d8fd64a393ca6887 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 27 Aug 2025 13:22:35 -0700 Subject: [PATCH 3/3] fix tests --- tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php | 2 +- .../EmailNotificationsToAdminAlertEmailUponCheckinTest.php | 6 +++++- .../EmailNotificationsToAdminAlertEmailUponCheckoutTest.php | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index f05c4389e6c1..c525f763ad63 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -58,7 +58,7 @@ public function testCanBulkCheckoutAssets() $this->assertHasTheseActionLogs($asset, ['create', 'checkout']); //Note: '$this' gets auto-bound in closures, so this does work. }); - Mail::assertSent(CheckoutAssetMail::class, 2); + Mail::assertSent(CheckoutAssetMail::class, 4); Mail::assertSent(CheckoutAssetMail::class, function (CheckoutAssetMail $mail) { return $mail->hasTo('someone@example.com'); }); diff --git a/tests/Feature/Notifications/Email/EmailNotificationsToAdminAlertEmailUponCheckinTest.php b/tests/Feature/Notifications/Email/EmailNotificationsToAdminAlertEmailUponCheckinTest.php index 1bdbf0b673f6..cc9a6cb2446e 100644 --- a/tests/Feature/Notifications/Email/EmailNotificationsToAdminAlertEmailUponCheckinTest.php +++ b/tests/Feature/Notifications/Email/EmailNotificationsToAdminAlertEmailUponCheckinTest.php @@ -51,8 +51,12 @@ public function test_admin_alert_email_sends() $this->fireCheckInEvent($this->asset, $this->user); + Mail::assertSentCount(2); Mail::assertSent(CheckinAssetMail::class, function ($mail) { - return $mail->hasTo($this->user->email) && $mail->hasCc('cc@example.com'); + return $mail->hasTo($this->user->email); + }); + Mail::assertSent(CheckinAssetMail::class, function ($mail) { + return $mail->hasTo('cc@example.com'); }); } diff --git a/tests/Feature/Notifications/Email/EmailNotificationsToAdminAlertEmailUponCheckoutTest.php b/tests/Feature/Notifications/Email/EmailNotificationsToAdminAlertEmailUponCheckoutTest.php index d881ae7dab66..3da0b21621cd 100644 --- a/tests/Feature/Notifications/Email/EmailNotificationsToAdminAlertEmailUponCheckoutTest.php +++ b/tests/Feature/Notifications/Email/EmailNotificationsToAdminAlertEmailUponCheckoutTest.php @@ -48,7 +48,7 @@ public function test_admin_alert_email_sends() $this->fireCheckoutEvent(); Mail::assertSent(CheckoutAssetMail::class, function (CheckoutAssetMail $mail) { - return $mail->hasCc('cc@example.com'); + return $mail->hasTo('cc@example.com'); }); }