mirror of
https://github.com/flarum/core.git
synced 2025-10-12 15:34:26 +02:00
fixed more attributes to match beta 8
This commit is contained in:
@@ -84,7 +84,7 @@ class CreatePostController extends AbstractCreateController
|
||||
}
|
||||
|
||||
$discussion = $post->discussion;
|
||||
$discussion->posts = $discussion->posts()->whereVisibleTo($actor)->orderBy('time')->pluck('id');
|
||||
$discussion->posts = $discussion->posts()->whereVisibleTo($actor)->orderBy('created_at')->pluck('id');
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ class BasicPostSerializer extends AbstractSerializer
|
||||
$attributes = [
|
||||
'id' => (int) $post->id,
|
||||
'number' => (int) $post->number,
|
||||
'time' => $this->formatDate($post->time),
|
||||
'time' => $this->formatDate($post->created_at),
|
||||
'contentType' => $post->type
|
||||
];
|
||||
|
||||
|
@@ -14,16 +14,17 @@ namespace Flarum\Api\Serializer;
|
||||
class CurrentUserSerializer extends UserSerializer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param \Flarum\User\User $user
|
||||
* @return array
|
||||
*/
|
||||
protected function getDefaultAttributes($user)
|
||||
{
|
||||
$attributes = parent::getDefaultAttributes($user);
|
||||
|
||||
$attributes += [
|
||||
'isActivated' => (bool) $user->is_activated,
|
||||
'isActivated' => (bool) $user->is_email_confirmed,
|
||||
'email' => $user->email,
|
||||
'readTime' => $this->formatDate($user->read_time),
|
||||
'readTime' => $this->formatDate($user->read_notifications_at),
|
||||
'unreadNotificationsCount' => (int) $user->getUnreadNotificationsCount(),
|
||||
'newNotificationsCount' => (int) $user->getNewNotificationsCount(),
|
||||
'preferences' => (array) $user->preferences
|
||||
|
@@ -57,8 +57,8 @@ class DiscussionSerializer extends BasicDiscussionSerializer
|
||||
|
||||
if ($state = $discussion->state) {
|
||||
$attributes += [
|
||||
'readTime' => $this->formatDate($state->read_time),
|
||||
'readNumber' => (int) $state->read_number
|
||||
'readTime' => $this->formatDate($state->last_read_at),
|
||||
'readNumber' => (int) $state->last_read_post_number
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -47,12 +47,13 @@ class NotificationSerializer extends AbstractSerializer
|
||||
'id' => (int) $notification->id,
|
||||
'contentType' => $notification->type,
|
||||
'content' => $notification->data,
|
||||
'time' => $this->formatDate($notification->time),
|
||||
'isRead' => (bool) $notification->is_read
|
||||
'time' => $this->formatDate($notification->created_at),
|
||||
'isRead' => (bool) $notification->read_at
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Notification $notification
|
||||
* @return \Tobscure\JsonApi\Relationship
|
||||
*/
|
||||
protected function user($notification)
|
||||
@@ -61,6 +62,7 @@ class NotificationSerializer extends AbstractSerializer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Notification $notification
|
||||
* @return \Tobscure\JsonApi\Relationship
|
||||
*/
|
||||
protected function sender($notification)
|
||||
@@ -69,6 +71,7 @@ class NotificationSerializer extends AbstractSerializer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Notification $notification
|
||||
* @return \Tobscure\JsonApi\Relationship
|
||||
*/
|
||||
protected function subject($notification)
|
||||
|
@@ -55,13 +55,13 @@ class PostSerializer extends BasicPostSerializer
|
||||
$attributes['content'] = $post->content;
|
||||
}
|
||||
|
||||
if ($post->edit_time) {
|
||||
$attributes['editTime'] = $this->formatDate($post->edit_time);
|
||||
if ($post->edited_at) {
|
||||
$attributes['editTime'] = $this->formatDate($post->edited_at);
|
||||
}
|
||||
|
||||
if ($post->hide_time) {
|
||||
if ($post->hidden_at) {
|
||||
$attributes['isHidden'] = true;
|
||||
$attributes['hideTime'] = $this->formatDate($post->hide_time);
|
||||
$attributes['hideTime'] = $this->formatDate($post->hidden_at);
|
||||
}
|
||||
|
||||
$attributes += [
|
||||
|
@@ -29,7 +29,8 @@ class UserSerializer extends BasicUserSerializer
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param \Flarum\User\User $user
|
||||
* @return array
|
||||
*/
|
||||
protected function getDefaultAttributes($user)
|
||||
{
|
||||
@@ -40,22 +41,22 @@ class UserSerializer extends BasicUserSerializer
|
||||
$canEdit = $gate->allows('edit', $user);
|
||||
|
||||
$attributes += [
|
||||
'joinTime' => $this->formatDate($user->join_time),
|
||||
'discussionsCount' => (int) $user->discussions_count,
|
||||
'commentsCount' => (int) $user->comments_count,
|
||||
'joinTime' => $this->formatDate($user->joined_at),
|
||||
'discussionsCount' => (int) $user->discussion_count,
|
||||
'commentsCount' => (int) $user->comment_count,
|
||||
'canEdit' => $canEdit,
|
||||
'canDelete' => $gate->allows('delete', $user),
|
||||
];
|
||||
|
||||
if ($user->getPreference('discloseOnline')) {
|
||||
$attributes += [
|
||||
'lastSeenTime' => $this->formatDate($user->last_seen_time)
|
||||
'lastSeenTime' => $this->formatDate($user->last_seen_at)
|
||||
];
|
||||
}
|
||||
|
||||
if ($canEdit || $this->actor->id === $user->id) {
|
||||
$attributes += [
|
||||
'isActivated' => (bool) $user->is_activated,
|
||||
'isActivated' => (bool) $user->is_email_confirmed,
|
||||
'email' => $user->email
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user