Convert other imports to Rabbit

This commit is contained in:
Jeremy Benoist
2016-09-04 21:49:21 +02:00
parent ef75e1220e
commit c98db1b653
14 changed files with 334 additions and 263 deletions

View File

@ -31,7 +31,7 @@ class WallabagV1Import extends WallabagImport
/**
* {@inheritdoc}
*/
protected function prepareEntry($entry = [], $markAsRead = false)
protected function prepareEntry($entry = [])
{
$data = [
'title' => $entry['title'],
@ -39,7 +39,7 @@ class WallabagV1Import extends WallabagImport
'url' => $entry['url'],
'content_type' => '',
'language' => '',
'is_archived' => $entry['is_read'] || $markAsRead,
'is_archived' => $entry['is_read'] || $this->markAsRead,
'is_starred' => $entry['is_fav'],
'tags' => '',
];
@ -56,4 +56,20 @@ class WallabagV1Import extends WallabagImport
return $data;
}
protected function parseEntriesForProducer($entries)
{
foreach ($entries as $importedEntry) {
// set userId for the producer (it won't know which user is connected)
$importedEntry['userId'] = $this->user->getId();
if ($this->markAsRead) {
$importedEntry['is_read'] = 1;
}
++$this->importedEntries;
$this->producer->publish(json_encode($importedEntry));
}
}
}