feat(composer): Ajoute exbil/mailcow-php-api et met à jour les dépendances.

 feat(CustomerDnsEmail): Ajoute un champ 'isBilling' à l'entité.

♻️ refactor(.env): Ajoute la clé MAILCOW_KEY pour l'API Mailcow.

 feat(CustomerController): Synchronise les boîtes mail Mailcow avec CustomerDnsEmail.
This commit is contained in:
Serreau Jovann
2025-09-27 13:18:59 +02:00
parent f3e5ff5c20
commit 5cf83c0cf2
6 changed files with 148 additions and 4 deletions

1
.env
View File

@@ -73,3 +73,4 @@ AMAZON_SES_SECRET=BD63dADmgFJJPnjlT9utRDlvcOh8pRH3eOZXsyhNL/F3
# MAILER_DSN=ses+smtp://ACCESS_KEY:SECRET_KEY@default?region=eu-west-1
###< symfony/amazon-mailer ###
CLOUDFLARE_TOKEN=4mqx9d7ynvoeCaXonJA07U19rH8gGhctqp7j2Lch
MAILCOW_KEY=DF0E7E-0FD059-16226F-8ECFF1-E558B3

View File

@@ -9,6 +9,7 @@
"ext-dom": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-zip": "*",
"chillerlan/php-qrcode": "*",
"cocur/slugify": "*",
"doctrine/dbal": "^3.10",
@@ -17,6 +18,7 @@
"doctrine/orm": "^3.5",
"docusealco/docuseal-php": "*",
"endroid/qr-code": "*",
"exbil/mailcow-php-api": "*",
"fpdf/fpdf": "*",
"google/cloud": "^0.296.0",
"imagine/imagine": "^1.5",
@@ -72,8 +74,7 @@
"twig/extra-bundle": "^3.21",
"twig/intl-extra": "^3.21",
"twig/twig": "^3.21",
"vich/uploader-bundle": "^2.7",
"ext-zip": "*"
"vich/uploader-bundle": "^2.7"
},
"config": {
"allow-plugins": {

76
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0291e06c5efd73a484876de6d294ec4c",
"content-hash": "b8dcaed57c743f84da5eed8dc6ae6db2",
"packages": [
{
"name": "async-aws/core",
@@ -2134,6 +2134,77 @@
],
"time": "2025-07-13T19:59:45+00:00"
},
{
"name": "exbil/mailcow-php-api",
"version": "0.14.2",
"source": {
"type": "git",
"url": "https://github.com/Exbil/mailcow-php-api.git",
"reference": "54357004d003d7825ab1b060419bd0a74b7a995a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Exbil/mailcow-php-api/zipball/54357004d003d7825ab1b060419bd0a74b7a995a",
"reference": "54357004d003d7825ab1b060419bd0a74b7a995a",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/guzzle": "^7.5",
"php": ">=7.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5.0"
},
"type": "library",
"autoload": {
"files": [
"src/MailCowAPI.php",
"src/Credentials.php"
],
"psr-4": {
"Exbil\\Mailcow\\": "src/"
},
"classmap": [
"src"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0-or-later"
],
"authors": [
{
"name": "Efe Bagri",
"email": "composer@exbil.net",
"homepage": "https://www.exbil.net"
},
{
"name": "Kees van Kempen",
"homepage": "https://github.com/keessaus"
},
{
"name": "Bryan Böhnke-Avan",
"email": "github@openducks.org",
"homepage": "https://openducks.org"
}
],
"description": "A full-featured implementation of the MailCow API",
"keywords": [
"API-Client",
"api",
"mailcow",
"mailcow-api",
"php",
"php-api-client",
"rest"
],
"support": {
"issues": "https://github.com/exbil/mailcow-php-api/issues",
"source": "https://github.com/exbil/mailcow-php-api"
},
"time": "2024-10-16T22:07:41+00:00"
},
{
"name": "firebase/php-jwt",
"version": "v6.11.1",
@@ -16141,7 +16212,8 @@
"ext-ctype": "*",
"ext-dom": "*",
"ext-iconv": "*",
"ext-libxml": "*"
"ext-libxml": "*",
"ext-zip": "*"
},
"platform-dev": {},
"plugin-api-version": "2.6.0"

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250927111842 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE customer_dns_email ADD is_billing BOOLEAN NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE customer_dns_email DROP is_billing');
}
}

View File

@@ -9,6 +9,7 @@ use App\Entity\CustomerContact;
use App\Entity\CustomerDevis;
use App\Entity\CustomerDevisLine;
use App\Entity\CustomerDns;
use App\Entity\CustomerDnsEmail;
use App\Entity\CustomerOrder;
use App\Entity\CustomerOrderLine;
use App\Entity\OrderNumberCurrent;
@@ -32,6 +33,7 @@ use App\Service\Logger\LoggerService;
use App\Service\Ovh\Client;
use AWS\CRT\Log;
use Doctrine\ORM\EntityManagerInterface;
use Exbil\MailCowAPI;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -288,6 +290,27 @@ class CustomerController extends AbstractController
$d = \DateTime::createFromFormat(\DateTime::ATOM,$data['expired']);
$customerNdd->setExpiredAt($d);
$entityManager->persist($customerNdd);
$client = new MailCowAPI('mail.esy-web.dev',$_ENV['MAILCOW_KEY']);
try {
foreach ($client->mailBoxes()->getMailBox($customerNdd->getNdd()) as $mailBox) {
$nddEmail = $entityManager->getRepository(CustomerDnsEmail::class)->findOneBy(['dns'=>$customerNdd,'email'=>$mailBox->local_part]);
if(!$nddEmail instanceof CustomerDnsEmail) {
$nddEmail = new CustomerDnsEmail();
$nddEmail->setEmail($mailBox->local_part);
$nddEmail->setDns($customerNdd);
$nddEmail->setIsBilling(true);
$nddEmail->setCreateAt(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s',$mailBox->created));
}
$nddEmail->setStorage($mailBox->quota);
$entityManager->persist($nddEmail);
}
$entityManager->flush();
}catch (\Exception $e){
}
$entityManager->flush();
}
}

View File

@@ -28,6 +28,9 @@ class CustomerDnsEmail
#[ORM\Column(length: 255)]
private ?string $storage = null;
#[ORM\Column]
private ?bool $isBilling = null;
public function getId(): ?int
{
return $this->id;
@@ -92,4 +95,16 @@ class CustomerDnsEmail
return $this;
}
public function isBilling(): ?bool
{
return $this->isBilling;
}
public function setIsBilling(bool $isBilling): static
{
$this->isBilling = $isBilling;
return $this;
}
}