forked from wallabag/wallabag
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.
This commit is contained in:
@ -193,6 +193,11 @@ class PocketImport extends AbstractImport
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see https://getpocket.com/developer/docs/v3/retrieve
|
||||
*/
|
||||
public function parseEntry(array $importedEntry)
|
||||
{
|
||||
$url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
|
||||
|
||||
@ -89,6 +89,9 @@ class ReadabilityImport extends AbstractImport
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function parseEntry(array $importedEntry)
|
||||
{
|
||||
$existingEntry = $this->em
|
||||
@ -108,6 +111,7 @@ class ReadabilityImport extends AbstractImport
|
||||
'language' => '',
|
||||
'is_archived' => $importedEntry['archive'] || $this->markAsRead,
|
||||
'is_starred' => $importedEntry['favorite'],
|
||||
'created_at' => $importedEntry['date_added'],
|
||||
];
|
||||
|
||||
$entry = $this->fetchContent(
|
||||
@ -125,6 +129,7 @@ class ReadabilityImport extends AbstractImport
|
||||
|
||||
$entry->setArchived($data['is_archived']);
|
||||
$entry->setStarred($data['is_starred']);
|
||||
$entry->setCreatedAt(new \DateTime($data['created_at']));
|
||||
|
||||
$this->em->persist($entry);
|
||||
++$this->importedEntries;
|
||||
|
||||
@ -139,6 +139,10 @@ abstract class WallabagImport extends AbstractImport
|
||||
$entry->setArchived($data['is_archived']);
|
||||
$entry->setStarred($data['is_starred']);
|
||||
|
||||
if (!empty($data['created_at'])) {
|
||||
$entry->setCreatedAt(new \DateTime($data['created_at']));
|
||||
}
|
||||
|
||||
$this->em->persist($entry);
|
||||
++$this->importedEntries;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user