Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Clean up notifications.
James Cole6f558f424d8c
diff --git a/app/Listeners/Security/User/NotifiesUserAboutNewIpAddress.php b/app/Listeners/Security/User/NotifiesUserAboutNewIpAddress.phpindex a060ec528c..94f33fd69c 100644--- a/app/Listeners/Security/User/NotifiesUserAboutNewIpAddress.php+++ b/app/Listeners/Security/User/NotifiesUserAboutNewIpAddress.php@@ -26,6 +26,7 @@ namespace FireflyIII\Listeners\Security\User;use Exception;use FireflyIII\Events\Security\User\UserLoggedInFromNewIpAddress;+use FireflyIII\Notifications\NotificationSender;use FireflyIII\Notifications\User\UserLogin;use FireflyIII\Support\Facades\Preferences;use Illuminate\Contracts\Queue\ShouldQueue;@@ -50,23 +51,7 @@ class NotifiesUserAboutNewIpAddress implements ShouldQueue/** @var array $entry */foreach ($list as $index => $entry) {if (false === $entry['notified']) {- try {- Notification::send($user, new UserLogin());- } catch (Exception $e) {- $message = $e->getMessage();- if (str_contains($message, 'Bcc')) {- Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- if (str_contains($message, 'RFC 2822')) {- Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- Log::error($e->getMessage());- Log::error($e->getTraceAsString());- }+ NotificationSender::send($user, new UserLogin());}$list[$index]['notified'] = true;}diff --git a/app/Listeners/Security/User/NotifiesUserAboutNoCodesLeft.php b/app/Listeners/Security/User/NotifiesUserAboutNoCodesLeft.phpindex d4fc58cee7..f77a326c17 100644--- a/app/Listeners/Security/User/NotifiesUserAboutNoCodesLeft.php+++ b/app/Listeners/Security/User/NotifiesUserAboutNoCodesLeft.php@@ -26,6 +26,7 @@ namespace FireflyIII\Listeners\Security\User;use Exception;use FireflyIII\Events\Security\User\UserHasNoMFABackupCodesLeft;+use FireflyIII\Notifications\NotificationSender;use FireflyIII\Notifications\Security\MFABackupNoLeftNotification;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Support\Facades\Log;@@ -39,22 +40,6 @@ class NotifiesUserAboutNoCodesLeft implements ShouldQueue$user = $event->user;- try {- Notification::send($user, new MFABackupNoLeftNotification($user));- } catch (Exception $e) {- $message = $e->getMessage();- if (str_contains($message, 'Bcc')) {- Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- if (str_contains($message, 'RFC 2822')) {- Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- Log::error($e->getMessage());- Log::error($e->getTraceAsString());- }+ NotificationSender::send($user, new MFABackupNoLeftNotification($user));}}diff --git a/app/Listeners/Security/User/NotifiesUserAboutRepeatedMFAFailures.php b/app/Listeners/Security/User/NotifiesUserAboutRepeatedMFAFailures.phpindex 37ae019d19..29c565dff5 100644--- a/app/Listeners/Security/User/NotifiesUserAboutRepeatedMFAFailures.php+++ b/app/Listeners/Security/User/NotifiesUserAboutRepeatedMFAFailures.php@@ -26,6 +26,7 @@ namespace FireflyIII\Listeners\Security\User;use Exception;use FireflyIII\Events\Security\User\UserKeepsFailingMFA;+use FireflyIII\Notifications\NotificationSender;use FireflyIII\Notifications\Security\MFAManyFailedAttemptsNotification;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Support\Facades\Log;@@ -39,23 +40,6 @@ class NotifiesUserAboutRepeatedMFAFailures implements ShouldQueue$user = $event->user;$count = $event->count;-- try {- Notification::send($user, new MFAManyFailedAttemptsNotification($user, $count));- } catch (Exception $e) {- $message = $e->getMessage();- if (str_contains($message, 'Bcc')) {- Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- if (str_contains($message, 'RFC 2822')) {- Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- Log::error($e->getMessage());- Log::error($e->getTraceAsString());- }+ NotificationSender::send($user, new MFAManyFailedAttemptsNotification($user, $count));}}diff --git a/app/Listeners/Security/User/NotifiesUserAboutUsedBackupCode.php b/app/Listeners/Security/User/NotifiesUserAboutUsedBackupCode.phpindex 9eb31d9169..e88811d698 100644--- a/app/Listeners/Security/User/NotifiesUserAboutUsedBackupCode.php+++ b/app/Listeners/Security/User/NotifiesUserAboutUsedBackupCode.php@@ -26,6 +26,7 @@ namespace FireflyIII\Listeners\Security\User;use Exception;use FireflyIII\Events\Security\User\UserHasUsedBackupCode;+use FireflyIII\Notifications\NotificationSender;use FireflyIII\Notifications\Security\MFAUsedBackupCodeNotification;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Support\Facades\Log;@@ -38,23 +39,6 @@ class NotifiesUserAboutUsedBackupCode implements ShouldQueueLog::debug(sprintf('Now in %s', __METHOD__));$user = $event->user;-- try {- Notification::send($user, new MFAUsedBackupCodeNotification($user));- } catch (Exception $e) {- $message = $e->getMessage();- if (str_contains($message, 'Bcc')) {- Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- if (str_contains($message, 'RFC 2822')) {- Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- Log::error($e->getMessage());- Log::error($e->getTraceAsString());- }+ NotificationSender::send($user, new MFAUsedBackupCodeNotification($user));}}diff --git a/app/Listeners/Security/User/SendsUserNewPassword.php b/app/Listeners/Security/User/SendsUserNewPassword.phpindex 43a35619eb..ff39cb2a94 100644--- a/app/Listeners/Security/User/SendsUserNewPassword.php+++ b/app/Listeners/Security/User/SendsUserNewPassword.php@@ -24,33 +24,15 @@ declare(strict_types=1);namespace FireflyIII\Listeners\Security\User;-use Exception;use FireflyIII\Events\Security\User\UserRequestedNewPassword;+use FireflyIII\Notifications\NotificationSender;use FireflyIII\Notifications\User\UserNewPassword;use Illuminate\Contracts\Queue\ShouldQueue;-use Illuminate\Support\Facades\Log;-use Illuminate\Support\Facades\Notification;class SendsUserNewPassword implements ShouldQueue{public function handle(UserRequestedNewPassword $event): void{- try {- Notification::send($event->user, new UserNewPassword(route('password.reset', [$event->token])));- } catch (Exception $e) {- $message = $e->getMessage();- if (str_contains($message, 'Bcc')) {- Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- if (str_contains($message, 'RFC 2822')) {- Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- Log::error($e->getMessage());- Log::error($e->getTraceAsString());- }+ NotificationSender::send($event->user, new UserNewPassword(route('password.reset', [$event->token])));}}diff --git a/app/Listeners/Test/SendsTestNotification.php b/app/Listeners/Test/SendsTestNotification.phpindex 21504285eb..91e2cb977c 100644--- a/app/Listeners/Test/SendsTestNotification.php+++ b/app/Listeners/Test/SendsTestNotification.php@@ -24,9 +24,9 @@ declare(strict_types=1);namespace FireflyIII\Listeners\Test;-use Exception;use FireflyIII\Events\Test\OwnerTestsNotificationChannel;use FireflyIII\Events\Test\UserTestsNotificationChannel;+use FireflyIII\Notifications\NotificationSender;use FireflyIII\Notifications\Test\OwnerTestNotificationEmail;use FireflyIII\Notifications\Test\OwnerTestNotificationPushover;use FireflyIII\Notifications\Test\OwnerTestNotificationSlack;@@ -34,11 +34,10 @@ use FireflyIII\Notifications\Test\UserTestNotificationEmail;use FireflyIII\Notifications\Test\UserTestNotificationPushover;use FireflyIII\Notifications\Test\UserTestNotificationSlack;use Illuminate\Support\Facades\Log;-use Illuminate\Support\Facades\Notification;class SendsTestNotification{- public function handle(OwnerTestsNotificationChannel|UserTestsNotificationChannel $event): void+ public function handle(OwnerTestsNotificationChannel | UserTestsNotificationChannel $event): void{Log::debug(sprintf('Now in SendsTestNotification::handle(%s->"%s")', get_class($event), $event->channel));@@ -82,24 +81,7 @@ class SendsTestNotificationreturn;}Log::debug(sprintf('Will send %s as a notification.', $class));-- try {- Notification::send($event->user, new $class());- } catch (Exception $e) {- $message = $e->getMessage();- if (str_contains($message, 'Bcc')) {- Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- if (str_contains($message, 'RFC 2822')) {- Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- Log::error($e->getMessage());- Log::error($e->getTraceAsString());- }+ NotificationSender::send($event->user, new $class());Log::debug(sprintf('If you see no errors above this line, test notification was sent over channel "%s"', $event->channel));}}