mirror of
https://github.com/flarum/core.git
synced 2025-07-22 01:01:28 +02:00
Don't include post content in the "basic" serializer
Currently all of a post's replies are loaded in full whenever the post is loaded, which is kind of overkill - we really just need to know that they exist (and who posted them) in order to render the "X replied to this" line.
This commit is contained in:
@@ -54,7 +54,7 @@ class DiscussionBasicSerializer extends AbstractSerializer
|
|||||||
*/
|
*/
|
||||||
protected function startPost($discussion)
|
protected function startPost($discussion)
|
||||||
{
|
{
|
||||||
return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostBasicSerializer');
|
return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostSerializer');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,7 +70,7 @@ class DiscussionBasicSerializer extends AbstractSerializer
|
|||||||
*/
|
*/
|
||||||
protected function lastPost($discussion)
|
protected function lastPost($discussion)
|
||||||
{
|
{
|
||||||
return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostBasicSerializer');
|
return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostSerializer');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,6 +86,6 @@ class DiscussionBasicSerializer extends AbstractSerializer
|
|||||||
*/
|
*/
|
||||||
protected function relevantPosts($discussion)
|
protected function relevantPosts($discussion)
|
||||||
{
|
{
|
||||||
return $this->hasMany($discussion, 'Flarum\Api\Serializer\PostBasicSerializer');
|
return $this->hasMany($discussion, 'Flarum\Api\Serializer\PostSerializer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,12 +43,6 @@ class PostBasicSerializer extends AbstractSerializer
|
|||||||
'contentType' => $post->type
|
'contentType' => $post->type
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($post instanceof CommentPost) {
|
|
||||||
$attributes['contentHtml'] = $post->content_html;
|
|
||||||
} else {
|
|
||||||
$attributes['content'] = $post->content;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $attributes;
|
return $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user