diff --git a/Mailcow/Mailcow.php b/Mailcow/Mailcow.php index 7d1da5ea6e..30138e146b 100644 --- a/Mailcow/Mailcow.php +++ b/Mailcow/Mailcow.php @@ -22,45 +22,45 @@ public function livestats() $status = "inactive"; $data = []; $attrs = $this->getAttrs(); - + // Fetch mailboxes $mailboxesResponse = parent::execute($this->url("mailbox/all"), $attrs); $mailboxes = json_decode($mailboxesResponse->getBody()); - + // Count mailboxes if ($mailboxes) { $data["mailboxes"] = count($mailboxes); } else { $data["mailboxes"] = 0; } - + // Fetch clients $domainsResponse = parent::execute($this->url("domain/all"), $attrs); $domains = json_decode($domainsResponse->getBody()); - + // Count clients if ($domains) { $data["domains"] = count($domains); } else { $data["domains"] = 0; } - + // Fetch messages $queueResponse = parent::execute($this->url("mailq/all"), $attrs); $queue = json_decode($queueResponse->getBody()); - + // Count messages if ($queue && isset($queue->messages)) { $data["queue"] = count($queue->messages); } else { $data["queue"] = 0; } - + // Determine status based on data if ($data["mailboxes"] > 0 || $data["domains"] > 0 || $data["queue"] >= 0) { $status = "active"; } - + return parent::getLiveStats($status, $data); } @@ -78,5 +78,4 @@ private function getAttrs() ], ]; } - }