Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortheworldbright <kent@kentshikama.com>2016-01-04 19:13:00 +0300
committerFrank Rousseau <frank.rousseau@free.fr>2018-11-01 15:56:18 +0300
commitea3395378f89e1cf81754c8b2bbf0a1828a39a34 (patch)
treed7d93914c217bc93768689a0c58e0725bf79d799 /app/services
parent47c7de22aec17254401e2bb83b580c98de7f3eb7 (diff)
Combine Comment index with Post show API route
Diffstat (limited to 'app/services')
-rw-r--r--app/services/post_service.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/services/post_service.rb b/app/services/post_service.rb
index a16523125..d0d203086 100644
--- a/app/services/post_service.rb
+++ b/app/services/post_service.rb
@@ -21,6 +21,22 @@ class PostService
end
end
+ def present_api_json
+ service = CommentService.new(post_id: post.id, user: user)
+ @presenter = PostPresenter.new(post, user)
+ @presenter.as_json.tap do |post|
+ post[:interactions] = ({comments: service.comments}).merge!(post[:interactions])
+ end
+ end
+
+ def present_json
+ PostPresenter.new(post, user)
+ end
+
+ def present_interactions_json
+ PostInteractionPresenter.new(post, user)
+ end
+
def mark_user_notifications(post_id)
return unless user
mark_comment_reshare_like_notifications_read(post_id)