1
0
Fork 1
forked from fedi/mastodon
mastodon/app/lib/inline_renderer.rb
Eugen Rochko 774ac47373
Add conversations API (#8832)
* Add conversations API

* Add web UI for conversations

* Add test for conversations API

* Add tests for ConversationAccount

* Improve web UI

* Rename ConversationAccount to AccountConversation

* Remove conversations on block and mute

* Change last_status_id to be a denormalization of status_ids

* Add optimistic locking
2018-10-07 23:44:58 +02:00

36 lines
852 B
Ruby

# frozen_string_literal: true
class InlineRenderer
def initialize(object, current_account, template)
@object = object
@current_account = current_account
@template = template
end
def render
case @template
when :status
serializer = REST::StatusSerializer
when :notification
serializer = REST::NotificationSerializer
when :conversation
serializer = REST::ConversationSerializer
else
return
end
serializable_resource = ActiveModelSerializers::SerializableResource.new(@object, serializer: serializer, scope: current_user, scope_name: :current_user)
serializable_resource.as_json
end
def self.render(object, current_account, template)
new(object, current_account, template).render
end
private
def current_user
@current_account&.user
end
end