mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Organised activity types and moved most to repos
Repos are generally better since otherwise we end up duplicating things between front-end and API. Types moved to by CONST values within a class for better visibilty of usage and listing of types.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
<?php namespace BookStack\Http\Controllers\Api;
|
||||
|
||||
use BookStack\Actions\ActivityType;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Repos\BookRepo;
|
||||
use BookStack\Exceptions\NotifyException;
|
||||
@ -55,8 +56,6 @@ class BookApiController extends ApiController
|
||||
$requestData = $this->validate($request, $this->rules['create']);
|
||||
|
||||
$book = $this->bookRepo->create($requestData);
|
||||
Activity::add($book, 'book_create', $book->id);
|
||||
|
||||
return response()->json($book);
|
||||
}
|
||||
|
||||
@ -80,7 +79,6 @@ class BookApiController extends ApiController
|
||||
|
||||
$requestData = $this->validate($request, $this->rules['update']);
|
||||
$book = $this->bookRepo->update($book, $requestData);
|
||||
Activity::add($book, 'book_update', $book->id);
|
||||
|
||||
return response()->json($book);
|
||||
}
|
||||
@ -96,8 +94,6 @@ class BookApiController extends ApiController
|
||||
$this->checkOwnablePermission('book-delete', $book);
|
||||
|
||||
$this->bookRepo->destroy($book);
|
||||
Activity::addMessage('book_delete', $book->name);
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
<?php namespace BookStack\Http\Controllers\Api;
|
||||
|
||||
use BookStack\Actions\ActivityType;
|
||||
use BookStack\Facades\Activity;
|
||||
use BookStack\Entities\Repos\BookshelfRepo;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
@ -63,7 +64,6 @@ class BookshelfApiController extends ApiController
|
||||
$bookIds = $request->get('books', []);
|
||||
$shelf = $this->bookshelfRepo->create($requestData, $bookIds);
|
||||
|
||||
Activity::add($shelf, 'bookshelf_create', $shelf->id);
|
||||
return response()->json($shelf);
|
||||
}
|
||||
|
||||
@ -94,12 +94,9 @@ class BookshelfApiController extends ApiController
|
||||
$this->checkOwnablePermission('bookshelf-update', $shelf);
|
||||
|
||||
$requestData = $this->validate($request, $this->rules['update']);
|
||||
|
||||
$bookIds = $request->get('books', null);
|
||||
|
||||
$shelf = $this->bookshelfRepo->update($shelf, $requestData, $bookIds);
|
||||
Activity::add($shelf, 'bookshelf_update', $shelf->id);
|
||||
|
||||
return response()->json($shelf);
|
||||
}
|
||||
|
||||
@ -115,8 +112,6 @@ class BookshelfApiController extends ApiController
|
||||
$this->checkOwnablePermission('bookshelf-delete', $shelf);
|
||||
|
||||
$this->bookshelfRepo->destroy($shelf);
|
||||
Activity::addMessage('bookshelf_delete', $shelf->name);
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
<?php namespace BookStack\Http\Controllers\Api;
|
||||
|
||||
use BookStack\Actions\ActivityType;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Repos\ChapterRepo;
|
||||
@ -58,8 +59,6 @@ class ChapterApiController extends ApiController
|
||||
$this->checkOwnablePermission('chapter-create', $book);
|
||||
|
||||
$chapter = $this->chapterRepo->create($request->all(), $book);
|
||||
Activity::add($chapter, 'chapter_create', $book->id);
|
||||
|
||||
return response()->json($chapter->load(['tags']));
|
||||
}
|
||||
|
||||
@ -83,8 +82,6 @@ class ChapterApiController extends ApiController
|
||||
$this->checkOwnablePermission('chapter-update', $chapter);
|
||||
|
||||
$updatedChapter = $this->chapterRepo->update($chapter, $request->all());
|
||||
Activity::add($chapter, 'chapter_update', $chapter->book->id);
|
||||
|
||||
return response()->json($updatedChapter->load(['tags']));
|
||||
}
|
||||
|
||||
@ -97,8 +94,6 @@ class ChapterApiController extends ApiController
|
||||
$this->checkOwnablePermission('chapter-delete', $chapter);
|
||||
|
||||
$this->chapterRepo->destroy($chapter);
|
||||
Activity::addMessage('chapter_delete', $chapter->name, $chapter->book->id);
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user