Fixed an oversight preventing the watch progress from being processed by backends.

This commit is contained in:
Abdulmhsen B. A. A.
2024-08-18 21:38:10 +03:00
parent a2ae3e6a33
commit a3b134b251
2 changed files with 29 additions and 17 deletions

View File

@@ -45,14 +45,28 @@ final readonly class ProcessProgressEvent
$e->stopPropagation(); $e->stopPropagation();
$options = $e->getOptions(); $options = $e->getOptions();
$entity = Container::get(iState::class)::fromArray($e->getData());
if (null === ($item = $this->db->get(Container::get(iState::class)::fromArray($e->getData())))) { if (null === ($item = $this->db->get($entity))) {
$writer(Level::Error, "Item with id '{id}' not found.", [ $writer(Level::Error, "Item '{title}' Is not referenced locally yet.", ['title' => $entity->getName()]);
'id' => ag($e->getData(), 'id', $e->getReference() ?? 'Unknown ID.') return $e;
}
if ($item->isWatched() || $entity->isWatched()) {
$writer(Level::Info, "Item '{id}: {title}' is marked as watched. Not updating watch process.", [
'id' => $item->id,
'title' => $item->getName()
]); ]);
return $e; return $e;
} }
$item = $item->apply($entity);
if (!$item->hasPlayProgress()) {
$writer(Level::Notice, "Item '{title}' has no watch progress to export.", ['title' => $item->title]);
return $e;
}
$list = []; $list = [];
$supported = Config::get('supported', []); $supported = Config::get('supported', []);

View File

@@ -74,22 +74,20 @@ final readonly class ProcessRequestEvent
$pEnabled = (bool)Config::get('sync.progress', false); $pEnabled = (bool)Config::get('sync.progress', false);
if (true === $pEnabled && true === $entity->hasPlayProgress() && !$entity->isWatched()) { if (true === $pEnabled && true === $entity->hasPlayProgress() && !$entity->isWatched()) {
if (null !== ($newEntity = $this->mapper->get($entity))) {
$logger->notice(r("Scheduling '{title}' for watch progress update via '{backend}' event.", [ $logger->notice(r("Scheduling '{title}' for watch progress update via '{backend}' event.", [
'backend' => $entity->via, 'backend' => $entity->via,
'title' => $entity->getName(), 'title' => $entity->getName(),
])); ]));
queueEvent(ProcessProgressEvent::NAME, [iState::COLUMN_ID => $newEntity->id], [ queueEvent(ProcessProgressEvent::NAME, $entity->getAll(), [
'unique' => true, 'unique' => true,
EventsTable::COLUMN_REFERENCE => r('{type}://{id}@{backend}', [ EventsTable::COLUMN_REFERENCE => r('{type}://{id}@{backend}', [
'type' => $newEntity->type, 'type' => $entity->type,
'backend' => $newEntity->via, 'backend' => $entity->via,
'id' => ag($newEntity->getMetadata($newEntity->via), iState::COLUMN_ID, '??'), 'id' => ag($entity->getMetadata($entity->via), iState::COLUMN_ID, '??'),
]), ]),
]); ]);
} }
}
$handler->close(); $handler->close();