Fixed an oversight preventing the watch progress from being processed by backends.
This commit is contained in:
@@ -45,14 +45,28 @@ final readonly class ProcessProgressEvent
|
||||
$e->stopPropagation();
|
||||
|
||||
$options = $e->getOptions();
|
||||
$entity = Container::get(iState::class)::fromArray($e->getData());
|
||||
|
||||
if (null === ($item = $this->db->get(Container::get(iState::class)::fromArray($e->getData())))) {
|
||||
$writer(Level::Error, "Item with id '{id}' not found.", [
|
||||
'id' => ag($e->getData(), 'id', $e->getReference() ?? 'Unknown ID.')
|
||||
if (null === ($item = $this->db->get($entity))) {
|
||||
$writer(Level::Error, "Item '{title}' Is not referenced locally yet.", ['title' => $entity->getName()]);
|
||||
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;
|
||||
}
|
||||
|
||||
$item = $item->apply($entity);
|
||||
|
||||
if (!$item->hasPlayProgress()) {
|
||||
$writer(Level::Notice, "Item '{title}' has no watch progress to export.", ['title' => $item->title]);
|
||||
return $e;
|
||||
}
|
||||
|
||||
$list = [];
|
||||
|
||||
$supported = Config::get('supported', []);
|
||||
|
||||
@@ -74,21 +74,19 @@ final readonly class ProcessRequestEvent
|
||||
|
||||
$pEnabled = (bool)Config::get('sync.progress', false);
|
||||
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.", [
|
||||
'backend' => $entity->via,
|
||||
'title' => $entity->getName(),
|
||||
]));
|
||||
$logger->notice(r("Scheduling '{title}' for watch progress update via '{backend}' event.", [
|
||||
'backend' => $entity->via,
|
||||
'title' => $entity->getName(),
|
||||
]));
|
||||
|
||||
queueEvent(ProcessProgressEvent::NAME, [iState::COLUMN_ID => $newEntity->id], [
|
||||
'unique' => true,
|
||||
EventsTable::COLUMN_REFERENCE => r('{type}://{id}@{backend}', [
|
||||
'type' => $newEntity->type,
|
||||
'backend' => $newEntity->via,
|
||||
'id' => ag($newEntity->getMetadata($newEntity->via), iState::COLUMN_ID, '??'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
queueEvent(ProcessProgressEvent::NAME, $entity->getAll(), [
|
||||
'unique' => true,
|
||||
EventsTable::COLUMN_REFERENCE => r('{type}://{id}@{backend}', [
|
||||
'type' => $entity->type,
|
||||
'backend' => $entity->via,
|
||||
'id' => ag($entity->getMetadata($entity->via), iState::COLUMN_ID, '??'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
$handler->close();
|
||||
|
||||
Reference in New Issue
Block a user