fix: corriger le parsing de l'API Mailcow pour getDomain et getDomainStatus
src/Service/MailcowService.php:
- getDomain(): l'API Mailcow retourne un objet JSON {} pour un seul
domaine (pas un tableau [{...}]). Ajout de la detection: si $data[0]
existe c'est un tableau, sinon c'est directement l'objet domaine
- getDomainStatus(): la cle du nombre de boites mail est
'mboxes_in_domain' (pas 'mbox_count' qui n'existe pas dans la reponse)
Resultat: Mailcow affiche maintenant correctement:
- siteconseil.fr: actif, 28 boites mail
- esy-web.dev: actif, 20 boites mail
- Autodiscover, autoconfig, SRV, MTA-STS: tous OK pour les 2 domaines
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -31,13 +31,14 @@ class MailcowService
|
||||
*/
|
||||
public function getDomain(string $domain): ?array
|
||||
{
|
||||
$domains = $this->request('GET', '/api/v1/get/domain/'.$domain);
|
||||
$data = $this->request('GET', '/api/v1/get/domain/'.$domain);
|
||||
|
||||
if ([] === $domains || !isset($domains[0])) {
|
||||
if ([] === $data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $domains[0];
|
||||
// L'API retourne soit un objet {}, soit un tableau [{...}]
|
||||
return isset($data[0]) ? $data[0] : $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +96,7 @@ class MailcowService
|
||||
|
||||
return [
|
||||
'active' => (bool) ($info['active'] ?? false),
|
||||
'mailboxes' => (int) ($info['mbox_count'] ?? 0),
|
||||
'mailboxes' => (int) ($info['mboxes_in_domain'] ?? 0),
|
||||
'quota' => (int) ($info['max_quota_for_domain'] ?? 0),
|
||||
'used_quota' => (int) ($info['bytes_total'] ?? 0),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user