Add support for authors

This commit is contained in:
Jeremy Benoist 2017-05-11 20:10:22 +02:00
parent e668a8124c
commit fb436e8ca0
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
2 changed files with 9 additions and 1 deletions

View file

@ -284,6 +284,7 @@ class EntryRestController extends WallabagRestController
* {"name"="language", "dataType"="string", "required"=false, "description"="Language of the entry"}, * {"name"="language", "dataType"="string", "required"=false, "description"="Language of the entry"},
* {"name"="preview_picture", "dataType"="string", "required"=false, "description"="Preview picture of the entry"}, * {"name"="preview_picture", "dataType"="string", "required"=false, "description"="Preview picture of the entry"},
* {"name"="published_at", "dataType"="datetime", "format"="YYYY-MM-DDTHH:II:SS+TZ", "required"=false, "description"="Published date of the entry"}, * {"name"="published_at", "dataType"="datetime", "format"="YYYY-MM-DDTHH:II:SS+TZ", "required"=false, "description"="Published date of the entry"},
* {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
* } * }
* ) * )
* *
@ -295,12 +296,14 @@ class EntryRestController extends WallabagRestController
$url = $request->request->get('url'); $url = $request->request->get('url');
$title = $request->request->get('title'); $title = $request->request->get('title');
$tags = $request->request->get('tags', []);
$isArchived = $request->request->get('archive'); $isArchived = $request->request->get('archive');
$isStarred = $request->request->get('starred'); $isStarred = $request->request->get('starred');
$content = $request->request->get('content'); $content = $request->request->get('content');
$language = $request->request->get('language'); $language = $request->request->get('language');
$picture = $request->request->get('preview_picture'); $picture = $request->request->get('preview_picture');
$publishedAt = $request->request->get('published_at'); $publishedAt = $request->request->get('published_at');
$authors = $request->request->get('authors', '');
$entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId()); $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId());
@ -322,6 +325,7 @@ class EntryRestController extends WallabagRestController
'open_graph' => [ 'open_graph' => [
'og_image' => $picture, 'og_image' => $picture,
], ],
'authors' => explode(',', $authors),
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -332,7 +336,7 @@ class EntryRestController extends WallabagRestController
$entry->setUrl($url); $entry->setUrl($url);
} }
$tags = $request->request->get('tags', []);
if (!empty($tags)) { if (!empty($tags)) {
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags); $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
} }

View file

@ -345,6 +345,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
'content' => 'my content', 'content' => 'my content',
'language' => 'de_DE', 'language' => 'de_DE',
'published_at' => '2016-09-08T11:55:58+0200', 'published_at' => '2016-09-08T11:55:58+0200',
'authors' => 'bob,helen',
]); ]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -361,6 +362,9 @@ class EntryRestControllerTest extends WallabagApiTestCase
$this->assertSame('my content', $content['content']); $this->assertSame('my content', $content['content']);
$this->assertSame('de_DE', $content['language']); $this->assertSame('de_DE', $content['language']);
$this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']); $this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']);
$this->assertCount(2, $content['published_by']);
$this->assertContains('bob', $content['published_by']);
$this->assertContains('helen', $content['published_by']);
} }
public function testPostSameEntry() public function testPostSameEntry()