diff --git a/framework/core/src/Api/Serializer/DiscussionBasicSerializer.php b/framework/core/src/Api/Serializer/DiscussionBasicSerializer.php index 99416b10e..ec5040f9d 100644 --- a/framework/core/src/Api/Serializer/DiscussionBasicSerializer.php +++ b/framework/core/src/Api/Serializer/DiscussionBasicSerializer.php @@ -54,7 +54,7 @@ class DiscussionBasicSerializer extends AbstractSerializer */ protected function startPost($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostSerializer'); + return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostBasicSerializer'); } /** @@ -70,7 +70,7 @@ class DiscussionBasicSerializer extends AbstractSerializer */ protected function lastPost($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostSerializer'); + return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostBasicSerializer'); } /** @@ -86,6 +86,14 @@ class DiscussionBasicSerializer extends AbstractSerializer */ protected function relevantPosts($discussion) { - return $this->hasMany($discussion, 'Flarum\Api\Serializer\PostSerializer'); + return $this->hasMany($discussion, 'Flarum\Api\Serializer\PostBasicSerializer'); + } + + /** + * @return \Tobscure\JsonApi\Relationship + */ + protected function hideUser($discussion) + { + return $this->hasOne($discussion, 'Flarum\Api\Serializer\UserBasicSerializer'); } } diff --git a/framework/core/src/Api/Serializer/DiscussionSerializer.php b/framework/core/src/Api/Serializer/DiscussionSerializer.php index 47ef8c0ea..eee9c38a0 100644 --- a/framework/core/src/Api/Serializer/DiscussionSerializer.php +++ b/framework/core/src/Api/Serializer/DiscussionSerializer.php @@ -64,12 +64,4 @@ class DiscussionSerializer extends DiscussionBasicSerializer return $attributes; } - - /** - * @return \Tobscure\JsonApi\Relationship - */ - protected function hideUser($discussion) - { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\UserSerializer'); - } } diff --git a/framework/core/src/Api/Serializer/PostBasicSerializer.php b/framework/core/src/Api/Serializer/PostBasicSerializer.php index 3a79eed84..962a7b28b 100644 --- a/framework/core/src/Api/Serializer/PostBasicSerializer.php +++ b/framework/core/src/Api/Serializer/PostBasicSerializer.php @@ -12,6 +12,7 @@ namespace Flarum\Api\Serializer; use Flarum\Core\Post; +use Flarum\Core\Post\CommentPost; use InvalidArgumentException; class PostBasicSerializer extends AbstractSerializer @@ -42,6 +43,12 @@ class PostBasicSerializer extends AbstractSerializer 'contentType' => $post->type ]; + if ($post instanceof CommentPost) { + $attributes['contentHtml'] = $post->content_html; + } else { + $attributes['content'] = $post->content; + } + return $attributes; }