mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-04 08:54:33 +08: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:
@ -13,9 +13,6 @@ class ActivityService
|
||||
protected $user;
|
||||
protected $permissionService;
|
||||
|
||||
/**
|
||||
* ActivityService constructor.
|
||||
*/
|
||||
public function __construct(Activity $activity, PermissionService $permissionService)
|
||||
{
|
||||
$this->activity = $activity;
|
||||
@ -26,23 +23,11 @@ class ActivityService
|
||||
/**
|
||||
* Add activity data to database.
|
||||
*/
|
||||
public function add(Entity $entity, string $activityKey, ?int $bookId = null)
|
||||
public function add(Entity $entity, string $type, ?int $bookId = null)
|
||||
{
|
||||
$activity = $this->newActivityForUser($activityKey, $bookId);
|
||||
$activity = $this->newActivityForUser($type, $bookId);
|
||||
$entity->activity()->save($activity);
|
||||
$this->setNotification($activityKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a activity history with a message, without binding to a entity.
|
||||
*/
|
||||
public function addMessage(string $activityKey, string $message, ?int $bookId = null)
|
||||
{
|
||||
$this->newActivityForUser($activityKey, $bookId)->forceFill([
|
||||
'extra' => $message
|
||||
])->save();
|
||||
|
||||
$this->setNotification($activityKey);
|
||||
$this->setNotification($type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
22
app/Actions/ActivityType.php
Normal file
22
app/Actions/ActivityType.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace BookStack\Actions;
|
||||
|
||||
class ActivityType
|
||||
{
|
||||
const PAGE_CREATE = 'page_create';
|
||||
const PAGE_UPDATE = 'page_update';
|
||||
const PAGE_DELETE = 'page_delete';
|
||||
const PAGE_RESTORE = 'page_restore';
|
||||
const PAGE_MOVE = 'page_move';
|
||||
const COMMENTED_ON = 'commented_on';
|
||||
const CHAPTER_CREATE = 'chapter_create';
|
||||
const CHAPTER_UPDATE = 'chapter_update';
|
||||
const CHAPTER_DELETE = 'chapter_delete';
|
||||
const CHAPTER_MOVE = 'chapter_move';
|
||||
const BOOK_CREATE = 'book_create';
|
||||
const BOOK_UPDATE = 'book_update';
|
||||
const BOOK_DELETE = 'book_delete';
|
||||
const BOOK_SORT = 'book_sort';
|
||||
const BOOKSHELF_CREATE = 'bookshelf_create';
|
||||
const BOOKSHELF_UPDATE = 'bookshelf_update';
|
||||
const BOOKSHELF_DELETE = 'bookshelf_delete';
|
||||
}
|
@ -44,6 +44,7 @@ class CommentRepo
|
||||
$comment->parent_id = $parent_id;
|
||||
|
||||
$entity->comments()->save($comment);
|
||||
Activity::add($entity, ActivityType::COMMENTED_ON, $entity->book->id);
|
||||
return $comment;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user