about summary refs log tree commit diff
path: root/app/presenters/tag_relationships_presenter.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-07-17 13:49:29 +0200
committerGitHub <noreply@github.com>2022-07-17 13:49:29 +0200
commitc3f0621a59a74d0e20e6db6170894871c48e8f0f (patch)
treedf58568b5fbb86042f9dad4ba772f47d305e6086 /app/presenters/tag_relationships_presenter.rb
parentecb3bb3256fe1bab0d7a63829cdce914b2b509a9 (diff)
Add ability to follow hashtags (#18809)
Diffstat (limited to 'app/presenters/tag_relationships_presenter.rb')
-rw-r--r--app/presenters/tag_relationships_presenter.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/presenters/tag_relationships_presenter.rb b/app/presenters/tag_relationships_presenter.rb
new file mode 100644
index 000000000..c3bdbaf07
--- /dev/null
+++ b/app/presenters/tag_relationships_presenter.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TagRelationshipsPresenter
+  attr_reader :following_map
+
+  def initialize(tags, current_account_id = nil, **options)
+    @following_map = begin
+      if current_account_id.nil?
+        {}
+      else
+        TagFollow.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:following_map] || {})
+      end
+    end
+  end
+end