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
path: root/app
diff options
context:
space:
mode:
authorJonne Haß <me@jhass.eu>2020-02-03 23:59:06 +0300
committerJonne Haß <me@jhass.eu>2020-02-04 20:54:53 +0300
commit04d0d6dccbee786a1e2b941d00ed8087fbf3c3f7 (patch)
tree07ec45dce2b8c556a358a8bd94cfc5564b9bcdc1 /app
parent08d4f87a2dbe6f82e25b0062c594275ad17b60d1 (diff)
API: return mentioned_people for comments
Diffstat (limited to 'app')
-rw-r--r--app/presenters/comment_presenter.rb29
1 files changed, 15 insertions, 14 deletions
diff --git a/app/presenters/comment_presenter.rb b/app/presenters/comment_presenter.rb
index 161c77718..17af87688 100644
--- a/app/presenters/comment_presenter.rb
+++ b/app/presenters/comment_presenter.rb
@@ -1,27 +1,28 @@
# frozen_string_literal: true
class CommentPresenter < BasePresenter
- def initialize(comment)
- @comment = comment
- end
-
def as_json(opts={})
{
- id: @comment.id,
- guid: @comment.guid,
- text: @comment.message.plain_text_for_json,
- author: @comment.author.as_api_response(:backbone),
- created_at: @comment.created_at,
- mentioned_people: @comment.mentioned_people.as_api_response(:backbone)
+ id: id,
+ guid: guid,
+ text: message.plain_text_for_json,
+ author: author.as_api_response(:backbone),
+ created_at: created_at,
+ mentioned_people: mentioned_people.as_api_response(:backbone)
}
end
def as_api_response
{
- guid: @comment.guid,
- body: @comment.message.plain_text_for_json,
- author: PersonPresenter.new(@comment.author).as_api_json,
- created_at: @comment.created_at
+ guid: guid,
+ body: message.plain_text_for_json,
+ author: PersonPresenter.new(author).as_api_json,
+ created_at: created_at,
+ mentioned_people: build_mentioned_people_json
}
end
+
+ def build_mentioned_people_json
+ mentioned_people.map {|m| PersonPresenter.new(m).as_api_json }
+ end
end