From 1e220c473fa71a412918a8e55b63949019b40744 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 10 Jun 2023 10:52:39 +0100 Subject: [PATCH] API: Fixed misaligned image datetime format For #4294 --- app/Uploads/Controllers/ImageGalleryApiController.php | 2 +- dev/api/responses/image-gallery-create.json | 4 ++-- dev/api/responses/image-gallery-read.json | 4 ++-- dev/api/responses/image-gallery-update.json | 4 ++-- tests/Api/ImageGalleryApiTest.php | 2 ++ 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/Uploads/Controllers/ImageGalleryApiController.php b/app/Uploads/Controllers/ImageGalleryApiController.php index 4fca6a4dd..c444ec663 100644 --- a/app/Uploads/Controllers/ImageGalleryApiController.php +++ b/app/Uploads/Controllers/ImageGalleryApiController.php @@ -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'] = []; diff --git a/dev/api/responses/image-gallery-create.json b/dev/api/responses/image-gallery-create.json index e27824491..0bf36d368 100644 --- a/dev/api/responses/image-gallery-create.json +++ b/dev/api/responses/image-gallery-create.json @@ -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", diff --git a/dev/api/responses/image-gallery-read.json b/dev/api/responses/image-gallery-read.json index c6c468daa..e3d5a92ca 100644 --- a/dev/api/responses/image-gallery-read.json +++ b/dev/api/responses/image-gallery-read.json @@ -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", diff --git a/dev/api/responses/image-gallery-update.json b/dev/api/responses/image-gallery-update.json index 6e6168a1b..e72961918 100644 --- a/dev/api/responses/image-gallery-update.json +++ b/dev/api/responses/image-gallery-update.json @@ -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", diff --git a/tests/Api/ImageGalleryApiTest.php b/tests/Api/ImageGalleryApiTest.php index 067173a6b..667093107 100644 --- a/tests/Api/ImageGalleryApiTest.php +++ b/tests/Api/ImageGalleryApiTest.php @@ -232,6 +232,8 @@ class ImageGalleryApiTest extends TestCase 'html' => "url}\" target=\"_blank\">\"{$image-name}\">", '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'));