about summary refs log tree commit diff
path: root/app/presenters
diff options
context:
space:
mode:
Diffstat (limited to 'app/presenters')
-rw-r--r--app/presenters/account_relationships_presenter.rb15
-rw-r--r--app/presenters/initial_state_presenter.rb5
-rw-r--r--app/presenters/instance_presenter.rb2
-rw-r--r--app/presenters/status_relationships_presenter.rb19
4 files changed, 41 insertions, 0 deletions
diff --git a/app/presenters/account_relationships_presenter.rb b/app/presenters/account_relationships_presenter.rb
new file mode 100644
index 000000000..657807863
--- /dev/null
+++ b/app/presenters/account_relationships_presenter.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AccountRelationshipsPresenter
+  attr_reader :following, :followed_by, :blocking,
+              :muting, :requested, :domain_blocking
+
+  def initialize(account_ids, current_account_id)
+    @following       = Account.following_map(account_ids, current_account_id)
+    @followed_by     = Account.followed_by_map(account_ids, current_account_id)
+    @blocking        = Account.blocking_map(account_ids, current_account_id)
+    @muting          = Account.muting_map(account_ids, current_account_id)
+    @requested       = Account.requested_map(account_ids, current_account_id)
+    @domain_blocking = Account.domain_blocking_map(account_ids, current_account_id)
+  end
+end
diff --git a/app/presenters/initial_state_presenter.rb b/app/presenters/initial_state_presenter.rb
new file mode 100644
index 000000000..75fef28a8
--- /dev/null
+++ b/app/presenters/initial_state_presenter.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+class InitialStatePresenter < ActiveModelSerializers::Model
+  attributes :settings, :token, :current_account, :admin
+end
diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb
index c96eaa1cb..19bedcc21 100644
--- a/app/presenters/instance_presenter.rb
+++ b/app/presenters/instance_presenter.rb
@@ -5,8 +5,10 @@ class InstancePresenter
     :closed_registrations_message,
     :site_contact_email,
     :open_registrations,
+    :site_title,
     :site_description,
     :site_extended_description,
+    :site_terms,
     to: Setting
   )
 
diff --git a/app/presenters/status_relationships_presenter.rb b/app/presenters/status_relationships_presenter.rb
new file mode 100644
index 000000000..caf00791a
--- /dev/null
+++ b/app/presenters/status_relationships_presenter.rb
@@ -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