Olivier Massot 10 ماه پیش
والد
کامیت
1a80feaef8

+ 1 - 0
doc/internal_requests.md

@@ -21,6 +21,7 @@ Ainsi, si l'on prend l'exemple d'une requête `/internal/download/123` envoyée
 * Un utilisateur hors VPN, même s'il connaissait le token, recevra une erreur 403, car n'ayant pas une ip autorisée
 * Une requête issue de la V1 avec le bon token et provenant d'une ip interne sera autorisée sans authentification
 * Une requête d'un utilisateur connecté en tant que super admin et à l'intérieur du VPN pourra aussi aboutir.
+
 ### Ip internes 
 
 Les ips considérées comme interne sont :

+ 1 - 2
src/Service/File/Storage/LocalStorage.php

@@ -322,8 +322,7 @@ class LocalStorage implements FileStorageInterface
     /**
      * Supprime récursivement un répertoire
      *
-     * (Au moment du développement, Gaufrette ne permet pas la suppression de répertoire, on laissera
-     * le soin à un cron de supprimer les répertoires vides du storage)
+     * (Au moment du développement, Gaufrette ne permet pas la suppression de répertoires)
      *
      * @param string $dirKey
      * @return void

+ 3 - 27
src/Service/Organization/OrganizationFactory.php

@@ -809,7 +809,7 @@ class OrganizationFactory
         $withError = false;
 
         try {
-            $orphanPersons = $this->getOrphansToBePersons($organization);
+            $orphanPersons = $this->getFutureOrphanPersons($organization);
 
             // On est obligé de supprimer manuellement les paramètres, car c'est l'entité Parameters qui est
             // propriétaire de la relation Organization ↔ Parameters.
@@ -884,7 +884,7 @@ class OrganizationFactory
      * @param Organization $organization
      * @return array<Person>
      */
-    protected function getOrphansToBePersons(Organization $organization): array
+    protected function getFutureOrphanPersons(Organization $organization): array
     {
         $orphans = [];
 
@@ -897,33 +897,9 @@ class OrganizationFactory
         return $orphans;
     }
 
-    // TODO: à revoir, c'est du many to many
-    //    protected function removeTypeOfPractices(Organization $organization): void {
-    //        foreach ($organization->getTypeOfPractices() as $typeOfPractice) {
-    //            $organization->removeTypeOfPractice($typeOfPractice);
-    //        }
-    //    }
-
-    // TODO: à revoir, c'est du many to many
-    //    protected function deleteContactPoints(Organization $organization): void
-    //    {
-    //        foreach ($organization->getContactPoints() as $contactPoint) {
-    //            $this->entityManager->remove($contactPoint);
-    //        }
-    //    }
-
-    // TODO: à revoir, c'est du many to many
-    //    protected function deleteBankAccounts(Organization $organization): void {
-    //        foreach ($organization->getBankAccounts() as $bankAccount) {
-    //            $this->entityManager->remove($bankAccount);
-    //        }
-    //    }
-
-
     protected function deleteTypo3Website(int $organizationId): void
     {
-        // TODO: implement
-        //        $this->typo3Service->deleteSite($organization->getId());
+        $this->typo3Service->hardDeleteSite($organizationId);
     }
 
     protected function switchDolibarrSocietyToProspect(Organization $organization): void

+ 19 - 2
src/Service/Typo3/Typo3Service.php

@@ -24,14 +24,15 @@ class Typo3Service
      *
      * @throws TransportExceptionInterface
      */
-    protected function sendCommand(string $route, array $parameters): ResponseInterface
+    protected function sendCommand(string $route, array $parameters, array $headers=[]): ResponseInterface
     {
         $url = UrlBuilder::concat(
             '/typo3',
             [$route],
             $parameters
         );
-        return $this->typo3_client->request('GET', $url);
+
+        return $this->typo3_client->request('GET', $url, $headers);
     }
 
     /**
@@ -74,6 +75,22 @@ class Typo3Service
         return $this->sendCommand('/otadmin/site/delete', ['organization-id' => $organizationId]);
     }
 
+    /**
+     * Permanently delete the organization's website.
+     *
+     * @throws TransportExceptionInterface
+     */
+    public function hardDeleteSite(int $organizationId): ResponseInterface
+    {
+        $headers = ['Confirmation-Token' => "DEL-$organizationId-".date('Ymd')];
+
+        return $this->sendCommand(
+            '/otadmin/site/delete',
+            ['organization-id' => $organizationId, 'hard' => 1],
+            $headers
+        );
+    }
+
     /**
      * Restore a website that has been deleted with 'deleteSite'.
      *

+ 1 - 0
tests/Fixture/Factory/Organization/OrganizationFactory.php

@@ -3,6 +3,7 @@
 namespace App\Tests\Fixture\Factory\Organization;
 
 use App\Entity\Organization\Organization;
+use App\Repository\Organization\OrganizationRepository;
 use Zenstruck\Foundry\ModelFactory;
 use Zenstruck\Foundry\Proxy;
 use Zenstruck\Foundry\RepositoryProxy;