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
{
$this->imageRepo->loadThumbs($image);
$data = $image->getAttributes();
$data = $image->toArray();
$data['created_by'] = $image->createdBy;
$data['updated_by'] = $image->updatedBy;
$data['content'] = [];

View File

@ -14,8 +14,8 @@
"name": "Admin",
"slug": "admin"
},
"updated_at": "2023-03-15 08:17:37",
"created_at": "2023-03-15 08:17:37",
"updated_at": "2023-03-15T16:32:09.000000Z",
"created_at": "2023-03-15T16:32:09.000000Z",
"id": 618,
"thumbs": {
"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,
"name": "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",
"updated_at": "2023-03-15 08:17:37",
"created_at": "2023-03-15T16:32:09.000000Z",
"updated_at": "2023-03-15T16:32:09.000000Z",
"created_by": {
"id": 1,
"name": "Admin",

View File

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