about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-11-06 15:22:44 +0100
committerThibaut Girka <thib@sitedethib.com>2018-11-06 15:22:44 +0100
commit36dab188fd83876ba5e0e08a4b6647a445e2f24f (patch)
tree28bdd407eac81bfcc2741ad2c1714192d774754a /app/services
parent34209c0340ca6b7c61de964a17f5f3fe2e0f7c7b (diff)
parent7775225d174bf7c413bcd41b89a5d50d32cc5cee (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'app/services')
-rw-r--r--app/services/hashtag_query_service.rb21
-rw-r--r--app/services/resolve_url_service.rb2
2 files changed, 22 insertions, 1 deletions
diff --git a/app/services/hashtag_query_service.rb b/app/services/hashtag_query_service.rb
new file mode 100644
index 000000000..86558a446
--- /dev/null
+++ b/app/services/hashtag_query_service.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class HashtagQueryService < BaseService
+  def call(tag, params, account = nil, local = false)
+    any  = tags_for(params[:any])
+    all  = tags_for(params[:all])
+    none = tags_for(params[:none])
+
+    @query = Status.as_tag_timeline(tag, account, local)
+                   .tagged_with_all(all)
+                   .tagged_with_none(none)
+    @query = @query.distinct.or(self.class.new.call(any, params.except(:any), account, local).distinct) if any
+    @query
+  end
+
+  private
+
+  def tags_for(tags)
+    Tag.where(name: tags.map(&:downcase)) if tags.presence
+  end
+end
diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb
index 1db1917e2..ed0c56923 100644
--- a/app/services/resolve_url_service.rb
+++ b/app/services/resolve_url_service.rb
@@ -20,7 +20,7 @@ class ResolveURLService < BaseService
   def process_url
     if equals_or_includes_any?(type, %w(Application Group Organization Person Service))
       FetchRemoteAccountService.new.call(atom_url, body, protocol)
-    elsif equals_or_includes_any?(type, %w(Note Article Image Video))
+    elsif equals_or_includes_any?(type, %w(Note Article Image Video Page))
       FetchRemoteStatusService.new.call(atom_url, body, protocol)
     end
   end