Commit 6e74ee7d authored by theworldbright's avatar theworldbright Committed by Jonne Haß

Make PostPresenter inherit from BasePresenter

closes #6315
parent 335b1c32
......@@ -9,6 +9,7 @@
* Refactor HomeController#toggle\_mobile [#6260](https://github.com/diaspora/diaspora/pull/6260)
* Extract CommentService from CommentsController [#6307](https://github.com/diaspora/diaspora/pull/6307)
* Extract user/profile discovery into the diaspora\_federation-rails gem [#6310](https://github.com/diaspora/diaspora/pull/6310)
* Refactor PostPresenter [#6315](https://github.com/diaspora/diaspora/pull/6315)
## Bug fixes
* Fix indentation and a link title on the default home page [#6212](https://github.com/diaspora/diaspora/pull/6212)
......
......@@ -7,7 +7,7 @@ class PostInteractionPresenter
def as_json(_options={})
{
likes: as_api(@post.likes),
reshares: PostPresenter.collection_json(@post.reshares, @current_user),
reshares: PostPresenter.as_collection(@post.reshares, :as_json, @current_user),
comments: CommentPresenter.as_collection(@post.comments.order("created_at ASC")),
participations: as_api(participations),
comments_count: @post.comments_count,
......
class PostPresenter
class PostPresenter < BasePresenter
include PostsHelper
attr_accessor :post, :current_user
attr_accessor :post
def initialize(post, current_user=nil)
@post = post
@current_user = current_user
end
def self.collection_json(collection, current_user)
collection.map {|post| PostPresenter.new(post, current_user) }
end
def as_json(_options={})
@post.include_root_in_json = false
@post.as_json(only: directly_retrieved_attributes).merge(non_directly_retrieved_attributes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment