From c98db1b653b5dc8b701422190b02d9fbf10c4e68 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 4 Sep 2016 21:49:21 +0200 Subject: Convert other imports to Rabbit --- .../ImportBundle/Import/WallabagV1Import.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/ImportBundle/Import/WallabagV1Import.php') diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php index 6cf3467a..86734652 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php @@ -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)); + } + } } -- cgit v1.2.3 From 3849a9f3231c0109c87af085452c3ac5e4aed303 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 5 Sep 2016 07:50:10 +0200 Subject: Some cleanup & refactor --- src/Wallabag/ImportBundle/Import/WallabagV1Import.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/Wallabag/ImportBundle/Import/WallabagV1Import.php') diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php index 86734652..292b72a7 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php @@ -57,19 +57,13 @@ class WallabagV1Import extends WallabagImport return $data; } - protected function parseEntriesForProducer($entries) + /** + * {@inheritdoc} + */ + protected function setEntryAsRead(array $importedEntry) { - foreach ($entries as $importedEntry) { - // set userId for the producer (it won't know which user is connected) - $importedEntry['userId'] = $this->user->getId(); + $importedEntry['is_read'] = 1; - if ($this->markAsRead) { - $importedEntry['is_read'] = 1; - } - - ++$this->importedEntries; - - $this->producer->publish(json_encode($importedEntry)); - } + return $importedEntry; } } -- cgit v1.2.3 From 6d65c0a8b089d3caa6f8e20d7935a9fe2f87d926 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 9 Sep 2016 09:36:07 +0200 Subject: Add ability to define created_at for all import At the moment only Readability & wallabag v2 import allow created_at import. Pocket removed `time_added` field from their API v2 to v3... And wallabag v1 doesn't export that value. --- src/Wallabag/ImportBundle/Import/WallabagV1Import.php | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Wallabag/ImportBundle/Import/WallabagV1Import.php') diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php index 292b72a7..4f001062 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php @@ -42,6 +42,7 @@ class WallabagV1Import extends WallabagImport 'is_archived' => $entry['is_read'] || $this->markAsRead, 'is_starred' => $entry['is_fav'], 'tags' => '', + 'created_at' => '', ]; // force content to be refreshed in case on bad fetch in the v1 installation -- cgit v1.2.3