mirror of
https://github.com/flarum/core.git
synced 2025-10-13 07:54:25 +02:00
Massive refactor
- Use contextual namespaces within Flarum\Core - Clean up and docblock everything - Refactor Activity/Notification blueprint stuff - Refactor Formatter stuff - Refactor Search stuff - Upgrade to JSON-API 1.0 - Removed “addedPosts” and “removedPosts” relationships from discussion API. This was used for adding/removing event posts after renaming a discussion etc. Instead we should make an additional request to get all new posts Todo: - Fix Extenders and extensions - Get rid of repository interfaces - Fix other bugs I’ve inevitably introduced
This commit is contained in:
@@ -3,17 +3,13 @@
|
||||
class UserSerializer extends UserBasicSerializer
|
||||
{
|
||||
/**
|
||||
* Serialize attributes of a User model for JSON output.
|
||||
*
|
||||
* @param User $user The User model to serialize.
|
||||
* @return array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function attributes($user)
|
||||
protected function getDefaultAttributes($user)
|
||||
{
|
||||
$attributes = parent::attributes($user);
|
||||
$attributes = parent::getDefaultAttributes($user);
|
||||
|
||||
$actingUser = $this->actor->getUser();
|
||||
$canEdit = $user->can($actingUser, 'edit');
|
||||
$canEdit = $user->can($this->actor, 'edit');
|
||||
|
||||
$attributes += [
|
||||
'bioHtml' => $user->bio_html,
|
||||
@@ -21,10 +17,10 @@ class UserSerializer extends UserBasicSerializer
|
||||
'discussionsCount' => (int) $user->discussions_count,
|
||||
'commentsCount' => (int) $user->comments_count,
|
||||
'canEdit' => $canEdit,
|
||||
'canDelete' => $user->can($actingUser, 'delete'),
|
||||
'canDelete' => $user->can($this->actor, 'delete'),
|
||||
];
|
||||
|
||||
if ($user->preference('discloseOnline')) {
|
||||
if ($user->getPreference('discloseOnline')) {
|
||||
$attributes += [
|
||||
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null
|
||||
];
|
||||
@@ -39,6 +35,6 @@ class UserSerializer extends UserBasicSerializer
|
||||
];
|
||||
}
|
||||
|
||||
return $this->extendAttributes($user, $attributes);
|
||||
return $attributes;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user