Refactor JSON templates to be generated with ActiveModelSerializers instead of Rabl (#4090)
This commit is contained in:
parent
2d6128672f
commit
8b2cad5637
80 changed files with 425 additions and 301 deletions
19
app/presenters/status_relationships_presenter.rb
Normal file
19
app/presenters/status_relationships_presenter.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class StatusRelationshipsPresenter
|
||||
attr_reader :reblogs_map, :favourites_map, :mutes_map
|
||||
|
||||
def initialize(statuses, current_account_id = nil)
|
||||
if current_account_id.nil?
|
||||
@reblogs_map = {}
|
||||
@favourites_map = {}
|
||||
@mutes_map = {}
|
||||
else
|
||||
status_ids = statuses.compact.flat_map { |s| [s.id, s.reblog_of_id] }.uniq
|
||||
conversation_ids = statuses.compact.map(&:conversation_id).compact.uniq
|
||||
@reblogs_map = Status.reblogs_map(status_ids, current_account_id)
|
||||
@favourites_map = Status.favourites_map(status_ids, current_account_id)
|
||||
@mutes_map = Status.mutes_map(conversation_ids, current_account_id)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue