API: Fixed misaligned image datetime format

For #4294
This commit is contained in:
Dan Brown 2023-06-10 10:52:39 +01:00
parent 59c7077fd9
commit 1e220c473f
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
5 changed files with 9 additions and 7 deletions

View file

@ -129,7 +129,7 @@ class ImageGalleryApiController extends ApiController
protected function formatForSingleResponse(Image $image): array protected function formatForSingleResponse(Image $image): array
{ {
$this->imageRepo->loadThumbs($image); $this->imageRepo->loadThumbs($image);
$data = $image->getAttributes(); $data = $image->toArray();
$data['created_by'] = $image->createdBy; $data['created_by'] = $image->createdBy;
$data['updated_by'] = $image->updatedBy; $data['updated_by'] = $image->updatedBy;
$data['content'] = []; $data['content'] = [];

View file

@ -14,8 +14,8 @@
"name": "Admin", "name": "Admin",
"slug": "admin" "slug": "admin"
}, },
"updated_at": "2023-03-15 08:17:37", "updated_at": "2023-03-15T16:32:09.000000Z",
"created_at": "2023-03-15 08:17:37", "created_at": "2023-03-15T16:32:09.000000Z",
"id": 618, "id": 618,
"thumbs": { "thumbs": {
"gallery": "https:\/\/bookstack.example.com\/uploads\/images\/gallery\/2023-03\/thumbs-150-150\/cute-cat-image.png", "gallery": "https:\/\/bookstack.example.com\/uploads\/images\/gallery\/2023-03\/thumbs-150-150\/cute-cat-image.png",

View file

@ -2,8 +2,8 @@
"id": 618, "id": 618,
"name": "cute-cat-image.png", "name": "cute-cat-image.png",
"url": "https:\/\/bookstack.example.com\/uploads\/images\/gallery\/2023-03\/cute-cat-image.png", "url": "https:\/\/bookstack.example.com\/uploads\/images\/gallery\/2023-03\/cute-cat-image.png",
"created_at": "2023-03-15 08:17:37", "created_at": "2023-03-15T16:32:09.000000Z",
"updated_at": "2023-03-15 08:17:37", "updated_at": "2023-03-15T16:32:09.000000Z",
"created_by": { "created_by": {
"id": 1, "id": 1,
"name": "Admin", "name": "Admin",

View file

@ -2,8 +2,8 @@
"id": 618, "id": 618,
"name": "My updated image name", "name": "My updated image name",
"url": "https:\/\/bookstack.example.com\/uploads\/images\/gallery\/2023-03\/cute-cat-image.png", "url": "https:\/\/bookstack.example.com\/uploads\/images\/gallery\/2023-03\/cute-cat-image.png",
"created_at": "2023-03-15 08:17:37", "created_at": "2023-03-15T16:32:09.000000Z",
"updated_at": "2023-03-15 08:24:50", "updated_at": "2023-03-15T18:31:14.000000Z",
"created_by": { "created_by": {
"id": 1, "id": 1,
"name": "Admin", "name": "Admin",

View file

@ -232,6 +232,8 @@ class ImageGalleryApiTest extends TestCase
'html' => "<a href=\"{$image->url}\" target=\"_blank\"><img src=\"{$displayUrl}\" alt=\"{$image->name}\"></a>", 'html' => "<a href=\"{$image->url}\" target=\"_blank\"><img src=\"{$displayUrl}\" alt=\"{$image->name}\"></a>",
'markdown' => "![{$image->name}]({$displayUrl})", 'markdown' => "![{$image->name}]({$displayUrl})",
], ],
'created_at' => $image->created_at->toISOString(),
'updated_at' => $image->updated_at->toISOString(),
]); ]);
$this->assertStringStartsWith('http://', $resp->json('thumbs.gallery')); $this->assertStringStartsWith('http://', $resp->json('thumbs.gallery'));
$this->assertStringStartsWith('http://', $resp->json('thumbs.display')); $this->assertStringStartsWith('http://', $resp->json('thumbs.display'));