From 6fc89824788d4f0d6f385b89d64e8e62ac92d84e Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 26 Jan 2023 12:59:33 -0800 Subject: [PATCH 1/5] Have acceptance result notifications adhere to alerts enabled setting --- app/Notifications/AcceptanceAssetAcceptedNotification.php | 5 +++++ app/Notifications/AcceptanceAssetDeclinedNotification.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/Notifications/AcceptanceAssetAcceptedNotification.php b/app/Notifications/AcceptanceAssetAcceptedNotification.php index c667588da..03a608fdd 100644 --- a/app/Notifications/AcceptanceAssetAcceptedNotification.php +++ b/app/Notifications/AcceptanceAssetAcceptedNotification.php @@ -46,6 +46,11 @@ class AcceptanceAssetAcceptedNotification extends Notification } + public function shouldSend($notifiable, $channel) + { + return $this->settings->alerts_enabled && ! empty($this->settings->alert_email); + } + /** * Get the mail representation of the notification. * diff --git a/app/Notifications/AcceptanceAssetDeclinedNotification.php b/app/Notifications/AcceptanceAssetDeclinedNotification.php index 944674735..5028a77fe 100644 --- a/app/Notifications/AcceptanceAssetDeclinedNotification.php +++ b/app/Notifications/AcceptanceAssetDeclinedNotification.php @@ -44,6 +44,11 @@ class AcceptanceAssetDeclinedNotification extends Notification } + public function shouldSend($notifiable, $channel) + { + return $this->settings->alerts_enabled && ! empty($this->settings->alert_email); + } + /** * Get the mail representation of the notification. * From 39289dd18e4257f34f36d9768e4e52af465856d6 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 26 Jan 2023 13:18:18 -0800 Subject: [PATCH 2/5] Use user provided alert email for checkout acceptances --- app/Models/CheckoutAcceptance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/CheckoutAcceptance.php b/app/Models/CheckoutAcceptance.php index 79a6da541..d68ac7ab7 100644 --- a/app/Models/CheckoutAcceptance.php +++ b/app/Models/CheckoutAcceptance.php @@ -21,7 +21,7 @@ class CheckoutAcceptance extends Model { // At this point the endpoint is the same for everything. // In the future this may want to be adapted for individual notifications. - return (config('mail.reply_to.address')) ? config('mail.reply_to.address') : '' ; + return Setting::getSettings()['alert_email']; } /** From 3580bdae86cfcecd0a257d95be861fb3f709af11 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 1 Feb 2023 11:44:35 -0800 Subject: [PATCH 3/5] Use object accessor instead of array accessor --- app/Models/CheckoutAcceptance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/CheckoutAcceptance.php b/app/Models/CheckoutAcceptance.php index d68ac7ab7..4cdc5b073 100644 --- a/app/Models/CheckoutAcceptance.php +++ b/app/Models/CheckoutAcceptance.php @@ -21,7 +21,7 @@ class CheckoutAcceptance extends Model { // At this point the endpoint is the same for everything. // In the future this may want to be adapted for individual notifications. - return Setting::getSettings()['alert_email']; + return Setting::getSettings()->alert_email; } /** From a45ce468cc8472f98d81fb78983830b064465d52 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 1 Feb 2023 11:44:56 -0800 Subject: [PATCH 4/5] Update return type for routing mail notifications --- app/Models/CheckoutAcceptance.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Models/CheckoutAcceptance.php b/app/Models/CheckoutAcceptance.php index 4cdc5b073..45fc6ec08 100644 --- a/app/Models/CheckoutAcceptance.php +++ b/app/Models/CheckoutAcceptance.php @@ -16,8 +16,12 @@ class CheckoutAcceptance extends Model 'declined_at' => 'datetime', ]; - // Get the mail recipient from the config - public function routeNotificationForMail(): string + /** + * Get the mail recipient from the config + * + * @return mixed|string|null + */ + public function routeNotificationForMail() { // At this point the endpoint is the same for everything. // In the future this may want to be adapted for individual notifications. From 58801dbb0b26856146464e6e96b854433d33eaae Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 16 Feb 2023 08:43:12 -0800 Subject: [PATCH 5/5] allows users to clear their slack settings --- app/Http/Livewire/SlackSettingsForm.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php index 1fda9a118..cd34b450a 100644 --- a/app/Http/Livewire/SlackSettingsForm.php +++ b/app/Http/Livewire/SlackSettingsForm.php @@ -39,6 +39,9 @@ class SlackSettingsForm extends Component if(empty($this->slack_channel || $this->slack_endpoint)){ $this->isDisabled= 'disabled'; } + if(empty($this->slack_endpoint && $this->slack_channel)){ + $this->isDisabled= ''; + } return view('livewire.slack-settings-form'); }