From b7b0f3cdcdeddbfafdda3babc9c674b4f6f3a67c Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sat, 23 May 2020 23:34:00 -0400 Subject: [PATCH] Fix errors from previous commits --- src/Api/Serializer/DiscussionSerializer.php | 8 ++++---- src/Api/Serializer/PostSerializer.php | 8 ++++---- src/Api/Serializer/UserSerializer.php | 4 ++-- src/User/Gate.php | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Api/Serializer/DiscussionSerializer.php b/src/Api/Serializer/DiscussionSerializer.php index 47ed11ecfd..c12670d29d 100644 --- a/src/Api/Serializer/DiscussionSerializer.php +++ b/src/Api/Serializer/DiscussionSerializer.php @@ -24,10 +24,10 @@ protected function getDefaultAttributes($discussion) 'createdAt' => $this->formatDate($discussion->created_at), 'lastPostedAt' => $this->formatDate($discussion->last_posted_at), 'lastPostNumber' => (int) $discussion->last_post_number, - 'canReply' => $this->user->can('reply', $discussion), - 'canRename' => $this->user->can('rename', $discussion), - 'canDelete' => $this->user->can('delete', $discussion), - 'canHide' => $this->user->can('hide', $discussion) + 'canReply' => $this->actor->can('reply', $discussion), + 'canRename' => $this->actor->can('rename', $discussion), + 'canDelete' => $this->actor->can('delete', $discussion), + 'canHide' => $this->actor->can('hide', $discussion) ]; if ($discussion->hidden_at) { diff --git a/src/Api/Serializer/PostSerializer.php b/src/Api/Serializer/PostSerializer.php index 4d7895283f..325c2d781c 100644 --- a/src/Api/Serializer/PostSerializer.php +++ b/src/Api/Serializer/PostSerializer.php @@ -22,13 +22,13 @@ protected function getDefaultAttributes($post) unset($attributes['content']); - $canEdit = $this->user->can('edit', $post); + $canEdit = $this->actor->can('edit', $post); if ($post instanceof CommentPost) { if ($canEdit) { $attributes['content'] = $post->content; } - if ($this->user->can('viewIps', $post)) { + if ($this->actor->can('viewIps', $post)) { $attributes['ipAddress'] = $post->ip_address; } } else { @@ -46,8 +46,8 @@ protected function getDefaultAttributes($post) $attributes += [ 'canEdit' => $canEdit, - 'canDelete' => $this->user->can('delete', $post), - 'canHide' => $this->user->can('hide', $post) + 'canDelete' => $this->actor->can('delete', $post), + 'canHide' => $this->actor->can('hide', $post) ]; return $attributes; diff --git a/src/Api/Serializer/UserSerializer.php b/src/Api/Serializer/UserSerializer.php index 4eb84c269b..78d3cb5545 100644 --- a/src/Api/Serializer/UserSerializer.php +++ b/src/Api/Serializer/UserSerializer.php @@ -19,14 +19,14 @@ protected function getDefaultAttributes($user) { $attributes = parent::getDefaultAttributes($user); - $canEdit = $this->user->can('edit', $user); + $canEdit = $this->actor->can('edit', $user); $attributes += [ 'joinTime' => $this->formatDate($user->joined_at), 'discussionCount' => (int) $user->discussion_count, 'commentCount' => (int) $user->comment_count, 'canEdit' => $canEdit, - 'canDelete' => $this->user->can('delete', $user), + 'canDelete' => $this->actor->can('delete', $user), ]; if ($user->getPreference('discloseOnline') || $this->actor->can('viewLastSeenAt', $user)) { diff --git a/src/User/Gate.php b/src/User/Gate.php index dd2d0cf823..699f85679e 100644 --- a/src/User/Gate.php +++ b/src/User/Gate.php @@ -17,7 +17,7 @@ class Gate /** * @var Dispatcher */ - protected static $events; + protected $events; /** * @param Dispatcher $events