aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller/EntryRestController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller/EntryRestController.php')
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index 31bb67fd..dfd04fb4 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -280,6 +280,10 @@ class EntryRestController extends WallabagRestController
280 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."}, 280 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
281 * {"name"="starred", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="entry already starred"}, 281 * {"name"="starred", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="entry already starred"},
282 * {"name"="archive", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="entry already archived"}, 282 * {"name"="archive", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="entry already archived"},
283 * {"name"="content", "dataType"="string", "required"=false, "description"="Content of the entry"},
284 * {"name"="language", "dataType"="string", "required"=false, "description"="Language of the entry"},
285 * {"name"="preview_picture", "dataType"="string", "required"=false, "description"="Preview picture of the entry"},
286 * {"name"="published_at", "dataType"="datetime", "format"="YYYY-MM-DDTHH:II:SS+TZ", "required"=false, "description"="Published date of the entry"},
283 * } 287 * }
284 * ) 288 * )
285 * 289 *
@@ -293,30 +297,42 @@ class EntryRestController extends WallabagRestController
293 $title = $request->request->get('title'); 297 $title = $request->request->get('title');
294 $isArchived = $request->request->get('archive'); 298 $isArchived = $request->request->get('archive');
295 $isStarred = $request->request->get('starred'); 299 $isStarred = $request->request->get('starred');
300 $content = $request->request->get('content');
301 $language = $request->request->get('language');
302 $picture = $request->request->get('preview_picture');
303 $publishedAt = $request->request->get('published_at');
296 304
297 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId()); 305 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId());
298 306
299 if (false === $entry) { 307 if (false === $entry) {
300 $entry = new Entry($this->getUser()); 308 $entry = new Entry($this->getUser());
301 try {
302 $entry = $this->get('wallabag_core.content_proxy')->updateEntry(
303 $entry,
304 $url
305 );
306 } catch (\Exception $e) {
307 $this->get('logger')->error('Error while saving an entry', [
308 'exception' => $e,
309 'entry' => $entry,
310 ]);
311 $entry->setUrl($url);
312 }
313 } 309 }
314 310
315 if (!is_null($title)) { 311 try {
316 $entry->setTitle($title); 312 $entry = $this->get('wallabag_core.content_proxy')->updateEntry(
313 $entry,
314 $url,
315 [
316 'title' => $title,
317 'html' => $content,
318 'url' => $url,
319 'language' => $language,
320 'date' => $publishedAt,
321 // faking the preview picture
322 'open_graph' => [
323 'og_image' => $picture,
324 ],
325 ]
326 );
327 } catch (\Exception $e) {
328 $this->get('logger')->error('Error while saving an entry', [
329 'exception' => $e,
330 'entry' => $entry,
331 ]);
332 $entry->setUrl($url);
317 } 333 }
318 334
319 $tags = $request->request->get('tags', ''); 335 $tags = $request->request->get('tags', []);
320 if (!empty($tags)) { 336 if (!empty($tags)) {
321 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags); 337 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
322 } 338 }