mirror of
https://github.com/flarum/core.git
synced 2025-10-10 06:24:26 +02:00
Improve some post/discussion permission logic
- Allow users to see their own posts, even if they have been hidden by someone else - Don't require hiding a post to be necessarily attributed to a user - Hide discussions with zero posts, unless the user can edit posts, or they are the discussion author
This commit is contained in:
@@ -87,7 +87,7 @@ class CommentPost extends Post
|
||||
* @param User $actor
|
||||
* @return $this
|
||||
*/
|
||||
public function hide(User $actor)
|
||||
public function hide(User $actor = null)
|
||||
{
|
||||
if ($this->number == 1) {
|
||||
throw new DomainException('Cannot hide the first post of a discussion');
|
||||
@@ -95,7 +95,7 @@ class CommentPost extends Post
|
||||
|
||||
if (! $this->hide_time) {
|
||||
$this->hide_time = time();
|
||||
$this->hide_user_id = $actor->id;
|
||||
$this->hide_user_id = $actor ? $actor->id : null;
|
||||
|
||||
$this->raise(new PostWasHidden($this));
|
||||
}
|
||||
|
Reference in New Issue
Block a user