Skip to content

Commit

Permalink
stop to try to write metadata on story
Browse files Browse the repository at this point in the history
  • Loading branch information
aynsix committed Dec 5, 2023
1 parent 66abd56 commit 77f02e7
Showing 1 changed file with 45 additions and 41 deletions.
86 changes: 45 additions & 41 deletions lib/Alchemy/Phrasea/WorkerManager/Subscriber/RecordSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,50 +162,54 @@ public function onRecordsWriteMeta(RecordsWriteMetaEvent $event)

$databox = $this->getApplicationBox()->get_databox($databoxId);
$record = $databox->get_record($recordId);
$type = $record->getType();

$subdefGroupe = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType());
// do not try to write meta on non story record
if (!$record->isStory()) {
$type = $record->getType();

if ($subdefGroupe !== null) {
$toWritemetaOriginalDocument = $subdefGroupe->toWritemetaOriginalDocument();
} else {
$toWritemetaOriginalDocument = true;
}
$subdefGroupe = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType());

foreach ($mediaSubdefs as $subdef) {
// check subdefmetadatarequired from the subview setup in admin
// check if we want to write meta in this mime type
if (in_array(trim($subdef->get_mime()), $acceptedMimeTypes) &&
(
($subdef->get_name() == 'document' && $toWritemetaOriginalDocument) ||
$this->isSubdefMetadataUpdateRequired($databox, $type, $subdef->get_name())
)
) {
$payload = [
'message_type' => MessagePublisher::WRITE_METADATAS_TYPE,
'payload' => [
'recordId' => $recordId,
'databoxId' => $databoxId,
'subdefName' => $subdef->get_name()
]
];
if ($subdef->is_physically_present()) {
$this->messagePublisher->publishMessage($payload, MessagePublisher::WRITE_METADATAS_TYPE);
}
else {
$logMessage = sprintf('Subdef "%s" is not physically present! to be passed in the retry q of "%s" ! payload >>> %s',
$subdef->get_name(),
MessagePublisher::WRITE_METADATAS_TYPE,
json_encode($payload)
);
$this->messagePublisher->pushLog($logMessage);

$this->messagePublisher->publishRetryMessage(
$payload,
MessagePublisher::WRITE_METADATAS_TYPE,
2,
'Subdef is not physically present!'
);
if ($subdefGroupe !== null) {
$toWritemetaOriginalDocument = $subdefGroupe->toWritemetaOriginalDocument();
} else {
$toWritemetaOriginalDocument = true;
}

foreach ($mediaSubdefs as $subdef) {
// check subdefmetadatarequired from the subview setup in admin
// check if we want to write meta in this mime type
if (in_array(trim($subdef->get_mime()), $acceptedMimeTypes) &&
(
($subdef->get_name() == 'document' && $toWritemetaOriginalDocument) ||
$this->isSubdefMetadataUpdateRequired($databox, $type, $subdef->get_name())
)
) {
$payload = [
'message_type' => MessagePublisher::WRITE_METADATAS_TYPE,
'payload' => [
'recordId' => $recordId,
'databoxId' => $databoxId,
'subdefName' => $subdef->get_name()
]
];
if ($subdef->is_physically_present()) {
$this->messagePublisher->publishMessage($payload, MessagePublisher::WRITE_METADATAS_TYPE);
}
else {
$logMessage = sprintf('Subdef "%s" is not physically present! to be passed in the retry q of "%s" ! payload >>> %s',
$subdef->get_name(),
MessagePublisher::WRITE_METADATAS_TYPE,
json_encode($payload)
);
$this->messagePublisher->pushLog($logMessage);

$this->messagePublisher->publishRetryMessage(
$payload,
MessagePublisher::WRITE_METADATAS_TYPE,
2,
'Subdef is not physically present!'
);
}
}
}
}
Expand Down

0 comments on commit 77f02e7

Please sign in to comment.