diff --git a/lib/Service/DirectoryService.php b/lib/Service/DirectoryService.php index e80f074c..706e9e9f 100644 --- a/lib/Service/DirectoryService.php +++ b/lib/Service/DirectoryService.php @@ -223,7 +223,14 @@ public function doCronSync(): array { $listings = $this->objectService->getObjects(objectType: 'listing'); // Extract unique directory URLs + // Get unique directories from listings $uniqueDirectories = array_unique(array_column($listings, 'directory')); + + // Add default OpenCatalogi directory if not already present + $defaultDirectory = 'https://directory.opencatalogi.nl/apps/opencatalogi/api/directory'; + if (!in_array($defaultDirectory, $uniqueDirectories)) { + $uniqueDirectories[] = $defaultDirectory; + } // Sync each unique directory foreach ($uniqueDirectories as $directoryUrl) { @@ -284,6 +291,9 @@ public function updateListing(array $newListing, array $oldListing): array{ */ public function syncExternalDirectory(string $url): array { + // Log successful broadcast + \OC::$server->getLogger()->info('Synchronizing directory with ' . $url); + // Get the directory data $result = $this->client->get($url); @@ -384,26 +394,6 @@ public function syncExternalDirectory(string $url): array ]; } - /** - * @todo - * - * @param string|null $id - * - * @return array - * @throws - */ - public function synchronise(?string $id = null): array - { - // Fetch the listing object by its ID - $object = $this->objectService->getObject('listing', $id); - - $url = $object['directory']; - -// $this->fetchFromExternalDirectory(url: $url, update: true); - - return $object; - } - /** * Copy or update a publication type from an external URL *