Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions lib/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ public function replaceRelatedOriginIds(array $object, array $config): array
if (isset($object[$key]) === false) {
continue;
}

if (
is_array($object[$key]) === true &&
$this->isAssociativeArray(reset($object[$key])) === true &&
Expand All @@ -1100,17 +1100,17 @@ public function replaceRelatedOriginIds(array $object, array $config): array
$object[$key][$i] = $this->replaceRelatedOriginIds($item, $subConfig);
}
}

} elseif ($this->isAssociativeArray($object[$key]) === true && is_array($subConfig) === true) {
// Single nested associative object
$object[$key] = $this->replaceRelatedOriginIds($object[$key], $subConfig);

} elseif ($subConfig === 'true' && is_string($object[$key]) === true) {
// Leaf: value is a string, marked for replacement
$object[$key] = $this->synchronizationContractMapper->findTargetIdByOriginId($object[$key]);
}
}

return $object;
}

Expand Down Expand Up @@ -1250,7 +1250,7 @@ private function updateIdsOnSubObjects(array $subObjectsConfig, string $synchron
continue;
}

if (is_array(reset($value)) === true && $this->isAssociativeArray(reset($value)) === true) {
if (is_array(reset($value)) === true && $this->isAssociativeArray(reset($value)) === true) {
foreach ($value as $key => $subValue) {
if (is_array($subValue) === false) {
continue;
Expand Down Expand Up @@ -2359,10 +2359,10 @@ private function fetchFile(Source $source, string $endpoint, array $config, stri
$fileService = $this->containerInterface->get('OCA\OpenRegister\Service\FileService');
$content = $response['body'];
$shouldShare = !empty($tags) && isset($config['autoShare']) ? $config['autoShare'] : false;

// Determine if file should be published based on the published parameter
$shouldPublish = $this->shouldPublishFile($published);

try {
$objectService = $this->containerInterface->get('OCA\OpenRegister\Service\ObjectService');
$objectEntity = $objectService->findByUuid(uuid: $objectId);
Expand All @@ -2373,7 +2373,7 @@ private function fetchFile(Source $source, string $endpoint, array $config, stri
share: $shouldShare,
tags: $tags
);

// Publish the file if needed
if ($shouldPublish && $file !== null) {
try {
Expand All @@ -2388,7 +2388,7 @@ private function fetchFile(Source $source, string $endpoint, array $config, stri
$register = $config['register'] ?? null;
$schema = $config['schema'] ?? null;
$file = $fileService->addFile(objectEntity: $objectId, fileName: $filename, content: $response['body'], share: isset($config['autoShare']) ? $config['autoShare'] : false, tags: $tags, register: $register, schema: $schema);

// For the addFile case, we'll need to get the object entity to publish
if ($shouldPublish && $file !== null) {
try {
Expand Down Expand Up @@ -2643,11 +2643,11 @@ private function processFetchFileRule(Rule $rule, array $data, ?string $objectId
$filename = null;
$tags = [];
$published = null;
$endpoint = $this->getFileContext(config: $config, endpoint: $object, filename: $filename, tags: $tags, objectId: $objectId, published: $published);
$endpointConfig = $this->getFileContext(config: $config, endpoint: $object, filename: $filename, tags: $tags, objectId: $objectId, published: $published);
if ($endpoint === null) {
continue;
}
$this->fetchFile(source: $source, endpoint: $endpoint, config: $config, objectId: $objectId, tags: $tags, filename: $filename, published: $published);
$this->fetchFile(source: $source, endpoint: $endpointConfig, config: $config, objectId: $objectId, tags: $tags, filename: $filename, published: $published);
}
break;
// Array of just endpoints
Expand All @@ -2666,7 +2666,7 @@ private function processFetchFileRule(Rule $rule, array $data, ?string $objectId

// Return data immediately with placeholder values
if (isset($config['setPlaceholder']) === false || (isset($config['setPlaceholder']) === true && $config['setPlaceholder'] != false)) {
$dataDot[$config['filePath']] = $this->generatePlaceholderValues($endpoint);
$dataDot[$config['filePath']] = $this->generatePlaceholderValues($endpoint);
}

return $dataDot->jsonSerialize();
Expand Down Expand Up @@ -3574,7 +3574,7 @@ private function shouldPublishFile(?string $published): bool
if ($date !== false) {
return true;
}

// Try other common date formats
$formats = ['Y-m-d', 'Y-m-d H:i:s', 'Y-m-d\TH:i:s\Z', 'Y-m-d\TH:i:sP'];
foreach ($formats as $format) {
Expand Down
Loading