Skip to content

Commit

Permalink
Making sure the cron job picks up de opencatalogi.directory
Browse files Browse the repository at this point in the history
And added loging to synchronysations
  • Loading branch information
rubenvdlinde committed Nov 2, 2024
1 parent f758fb4 commit e081282
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions lib/Service/DirectoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit e081282

Please sign in to comment.