about summary refs log tree commit diff
path: root/app/presenters
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-07-12 02:03:17 -0700
committerkibigo! <marrus-sh@users.noreply.github.com>2017-07-12 02:03:17 -0700
commit79d898ae0ad8c0e66bd63ec3e0904e9e5e7894e8 (patch)
treeee8d832ed2f11e9afe62daf0e586a86004eb8d98 /app/presenters
parentbcf7ee48e94cd2e4d2de28e8854e7f0e2b5cad1f (diff)
parent056b5ed72f6d980bceeb49eb249b8365fe8fce66 (diff)
Merge upstream!! #64 <3 <3
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