From c0c3fb6111d9e9d6f2c24bac71228f285e40720e Mon Sep 17 00:00:00 2001 From: Austin Best Date: Wed, 22 Nov 2023 12:31:10 -0500 Subject: [PATCH] Added/removed state notification fixes --- root/app/www/public/crons/state.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/root/app/www/public/crons/state.php b/root/app/www/public/crons/state.php index cf3f06b..ec8bb0f 100644 --- a/root/app/www/public/crons/state.php +++ b/root/app/www/public/crons/state.php @@ -21,18 +21,18 @@ $notify = $added = $removed = []; //-- CHECK FOR ADDED CONTAINERS +$matches = []; foreach ($previousStates as $previousIndex => $previousState) { $found = false; foreach ($currentStates as $currentIndex => $currentState) { - if ($settings['notifications']['triggers']['added']['active']) { - if ($previousState['Names'] == $currentState['Names']) { - $found = true; - break; - } + if ($previousState['Names'] == $currentState['Names']) { + $found = true; + break; } } - if (!$found) { - $added[] = ['container' => $currentState['Names']]; + if ($settings['notifications']['triggers']['added']['active'] && !in_array($currentState['Names'], $matches) && !$found) { + $added[] = ['container' => $currentState['Names']]; + $matches[] = $currentState['Names']; } } @@ -42,18 +42,18 @@ logger($logfile, 'Added containers: ' . json_encode($notify['state']['added'])); //-- CHECK FOR REMOVED CONTAINERS +$matches = []; foreach ($currentStates as $currentIndex => $currentState) { $found = false; foreach ($previousStates as $previousIndex => $previousState) { - if ($settings['notifications']['triggers']['removed']['active']) { - if ($previousState['Names'] == $currentState['Names']) { - $found = true; - break; - } + if ($previousState['Names'] == $currentState['Names']) { + $found = true; + break; } } - if (!$found) { - $removed[] = ['container' => $currentState['Names']]; + if ($settings['notifications']['triggers']['removed']['active'] && !in_array($currentState['Names'], $matches) && !$found) { + $removed[] = ['container' => $currentState['Names']]; + $matches[] = $currentState['Names']; } }