Skip to content

Commit

Permalink
API: Fixed misaligned image datetime format
Browse files Browse the repository at this point in the history
For #4294
  • Loading branch information
ssddanbrown committed Jun 10, 2023
1 parent 59c7077 commit 1e220c4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Uploads/Controllers/ImageGalleryApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function delete(string $id)
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'] = [];
Expand Down
4 changes: 2 additions & 2 deletions dev/api/responses/image-gallery-create.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions dev/api/responses/image-gallery-read.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions dev/api/responses/image-gallery-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tests/Api/ImageGalleryApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ public function test_read_endpoint()
'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'));
Expand Down

0 comments on commit 1e220c4

Please sign in to comment.