1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Touched entity timestamps on entity tag update

Decided it's relevant to entity updated_at since tags are now indexed
alongside content.

- Also fixed tags not applied on shelf.
- Also enforced proper page API update validation.
- Adds tests to cover.

For #3319
Fixes #3370
This commit is contained in:
Dan Brown
2022-04-04 17:24:05 +01:00
parent affae2e3c4
commit c30a9d3564
7 changed files with 84 additions and 14 deletions

View File

@ -12,7 +12,7 @@ use Illuminate\Http\Request;
class PageApiController extends ApiController
{
protected $pageRepo;
protected PageRepo $pageRepo;
protected $rules = [
'create' => [
@ -24,8 +24,8 @@ class PageApiController extends ApiController
'tags' => ['array'],
],
'update' => [
'book_id' => ['required', 'integer'],
'chapter_id' => ['required', 'integer'],
'book_id' => ['integer'],
'chapter_id' => ['integer'],
'name' => ['string', 'min:1', 'max:255'],
'html' => ['string'],
'markdown' => ['string'],
@ -103,6 +103,8 @@ class PageApiController extends ApiController
*/
public function update(Request $request, string $id)
{
$requestData = $this->validate($request, $this->rules['update']);
$page = $this->pageRepo->getById($id, []);
$this->checkOwnablePermission('page-update', $page);
@ -127,7 +129,7 @@ class PageApiController extends ApiController
}
}
$updatedPage = $this->pageRepo->update($page, $request->all());
$updatedPage = $this->pageRepo->update($page, $requestData);
return response()->json($updatedPage->forJsonDisplay());
}