Skip to content

Commit

Permalink
Added/removed state notification fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
austinwbest committed Nov 22, 2023
1 parent f5a198d commit c0c3fb6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions root/app/www/public/crons/state.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}

Expand All @@ -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'];
}
}

Expand Down

0 comments on commit c0c3fb6

Please sign in to comment.