From 3f31283ca3bdab9b31199c91396c49119e116479 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 5 Mar 2025 09:56:04 -0800 Subject: [PATCH] adds a null check for webhook_endpoint --- app/Models/Loggable.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Models/Loggable.php b/app/Models/Loggable.php index 1e4a912027..e323f3a897 100644 --- a/app/Models/Loggable.php +++ b/app/Models/Loggable.php @@ -224,6 +224,10 @@ trait Loggable { $log = new Actionlog; $location = Location::find($location_id); + $settings = Setting::getSettings(); + if (!$settings) { + throw new \RuntimeException('Settings not found.'); + } if (static::class == LicenseSeat::class) { $log->item_type = License::class; $log->item_id = $this->license_id; @@ -244,13 +248,13 @@ trait Loggable 'location' => ($location) ? $location->name : '', 'note' => $note, ]; - if(Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')){ + if($settings->webhook_selected === 'microsoft' && Str::contains($settings->webhook_endpoint, 'workflows')){ $message = AuditNotification::toMicrosoftTeams($params); - $notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint); + $notification = new TeamsNotification($settings->webhook_endpoint); $notification->success()->sendMessage($message[0], $message[1]); } - else { - Setting::getSettings()->notify(new AuditNotification($params)); + else if($settings->webhook_endpoint !== null) { + $settings->notify(new AuditNotification($params)); } return $log;