From ced83b9bfc525293f31efe7d7e91ce3f1feef344 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 5 Jan 2026 12:14:42 -0800 Subject: [PATCH 1/5] add a try catch to ms teams audit notification --- app/Models/Traits/Loggable.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/Models/Traits/Loggable.php b/app/Models/Traits/Loggable.php index 4ea08c1525..95d9a14d4b 100644 --- a/app/Models/Traits/Loggable.php +++ b/app/Models/Traits/Loggable.php @@ -10,10 +10,13 @@ use App\Models\Location; use App\Models\Setting; use App\Models\User; use App\Notifications\AuditNotification; +use GuzzleHttp\Exception\ConnectException; +use GuzzleHttp\Exception\RequestException; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use Osama\LaravelTeamsNotification\TeamsNotification; +use Throwable; trait Loggable { @@ -282,10 +285,28 @@ trait Loggable 'location' => ($location) ? $location->name : '', 'note' => $note, ]; + if(Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) { - $message = AuditNotification::toMicrosoftTeams($params); - $notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint); - $notification->success()->sendMessage($message[0], $message[1]); + try { + $endpoint = Setting::getSettings()->webhook_endpoint; + $message = AuditNotification::toMicrosoftTeams($params); + $notification = new TeamsNotification($endpoint); + + $notification->success()->sendMessage($message[0], $message[1]); + + } catch (ConnectException $e) { + Log::warning('Teams webhook connection failed', [ + 'endpoint' => Setting::getSettings()->webhook_endpoint, + 'error' => $e->getMessage(), + ]); + + } catch (Throwable $e) { + Log::error('Teams webhook failed unexpectedly', [ + 'endpoint' => Setting::getSettings()->webhook_endpoint, + 'exception' => get_class($e), + 'error' => $e->getMessage(), + ]); + } } else { Setting::getSettings()->notify(new AuditNotification($params)); From 201c4fa0d9cbca9526fa0d1679f3db7b1b8635ab Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 5 Jan 2026 12:15:37 -0800 Subject: [PATCH 2/5] remove use path --- app/Models/Traits/Loggable.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Models/Traits/Loggable.php b/app/Models/Traits/Loggable.php index 95d9a14d4b..cf54dbc373 100644 --- a/app/Models/Traits/Loggable.php +++ b/app/Models/Traits/Loggable.php @@ -11,7 +11,6 @@ use App\Models\Setting; use App\Models\User; use App\Notifications\AuditNotification; use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Exception\RequestException; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; From 2a60b7b7b2fb2d9f3ac38a3329568130a9735a5a Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 5 Jan 2026 12:31:00 -0800 Subject: [PATCH 3/5] move endpoint --- app/Models/Traits/Loggable.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Models/Traits/Loggable.php b/app/Models/Traits/Loggable.php index cf54dbc373..9a7336c417 100644 --- a/app/Models/Traits/Loggable.php +++ b/app/Models/Traits/Loggable.php @@ -286,8 +286,10 @@ trait Loggable ]; if(Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) { - try { + $endpoint = Setting::getSettings()->webhook_endpoint; + + try { $message = AuditNotification::toMicrosoftTeams($params); $notification = new TeamsNotification($endpoint); From b935752ec01976909e41900a9cefe0aaf36eeef2 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 5 Jan 2026 12:35:20 -0800 Subject: [PATCH 4/5] reference endpoint appropriately" --- app/Models/Traits/Loggable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Traits/Loggable.php b/app/Models/Traits/Loggable.php index 9a7336c417..569259bdca 100644 --- a/app/Models/Traits/Loggable.php +++ b/app/Models/Traits/Loggable.php @@ -297,13 +297,13 @@ trait Loggable } catch (ConnectException $e) { Log::warning('Teams webhook connection failed', [ - 'endpoint' => Setting::getSettings()->webhook_endpoint, + 'endpoint' => $endpoint, 'error' => $e->getMessage(), ]); } catch (Throwable $e) { Log::error('Teams webhook failed unexpectedly', [ - 'endpoint' => Setting::getSettings()->webhook_endpoint, + 'endpoint' => $endpoint, 'exception' => get_class($e), 'error' => $e->getMessage(), ]); From 1543634cb04c04f98152c14f1f758387e438ccc1 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 5 Jan 2026 12:39:28 -0800 Subject: [PATCH 5/5] remove line break --- app/Models/Traits/Loggable.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Models/Traits/Loggable.php b/app/Models/Traits/Loggable.php index 569259bdca..d38ac4066f 100644 --- a/app/Models/Traits/Loggable.php +++ b/app/Models/Traits/Loggable.php @@ -292,7 +292,6 @@ trait Loggable try { $message = AuditNotification::toMicrosoftTeams($params); $notification = new TeamsNotification($endpoint); - $notification->success()->sendMessage($message[0], $message[1]); } catch (ConnectException $e) {