about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorJenkins <jenkins@jenkins.ninjawedding.org>2017-12-06 20:17:13 +0000
committerJenkins <jenkins@jenkins.ninjawedding.org>2017-12-06 20:17:13 +0000
commit8ca91cef45417947607079118b1af07c9774ae58 (patch)
treecafbe6cc30563ca35ffa522056ead63ca450d9c1 /app/services
parentf2f2f1032082d6212771bd0307136484f671d37e (diff)
parenta0047fdca052088cce0e23c3b58b95f13be19805 (diff)
Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/account_search_service.rb22
-rw-r--r--app/services/activitypub/process_collection_service.rb2
-rw-r--r--app/services/authorize_follow_service.rb2
-rw-r--r--app/services/post_status_service.rb2
-rw-r--r--app/services/process_feed_service.rb2
-rw-r--r--app/services/remove_status_service.rb2
-rw-r--r--app/services/search_service.rb2
-rw-r--r--app/services/suspend_account_service.rb2
8 files changed, 20 insertions, 16 deletions
diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb
index b0c663d02..a289ceac4 100644
--- a/app/services/account_search_service.rb
+++ b/app/services/account_search_service.rb
@@ -1,12 +1,12 @@
 # frozen_string_literal: true
 
 class AccountSearchService < BaseService
-  attr_reader :query, :limit, :resolve, :account
+  attr_reader :query, :limit, :options, :account
 
-  def call(query, limit, resolve = false, account = nil)
-    @query = query
-    @limit = limit
-    @resolve = resolve
+  def call(query, limit, account = nil, options = {})
+    @query   = query
+    @limit   = limit
+    @options = options
     @account = account
 
     search_service_results
@@ -25,7 +25,7 @@ class AccountSearchService < BaseService
   end
 
   def resolving_non_matching_remote_account?
-    resolve && !exact_match && !domain_is_local?
+    options[:resolve] && !exact_match && !domain_is_local?
   end
 
   def search_results_and_exact_match
@@ -58,12 +58,16 @@ class AccountSearchService < BaseService
     @_domain_is_local ||= TagManager.instance.local_domain?(query_domain)
   end
 
+  def search_from
+    options[:following] && account ? account.following : Account
+  end
+
   def exact_match
     @_exact_match ||= begin
       if domain_is_local?
-        Account.find_local(query_username)
+        search_from.find_local(query_username)
       else
-        Account.find_remote(query_username, query_domain)
+        search_from.find_remote(query_username, query_domain)
       end
     end
   end
@@ -79,7 +83,7 @@ class AccountSearchService < BaseService
   end
 
   def advanced_search_results
-    Account.advanced_search_for(terms_for_query, account, limit)
+    Account.advanced_search_for(terms_for_query, account, limit, options[:following])
   end
 
   def simple_search_results
diff --git a/app/services/activitypub/process_collection_service.rb b/app/services/activitypub/process_collection_service.rb
index db4d1b4bc..eb93329e9 100644
--- a/app/services/activitypub/process_collection_service.rb
+++ b/app/services/activitypub/process_collection_service.rb
@@ -3,7 +3,7 @@
 class ActivityPub::ProcessCollectionService < BaseService
   include JsonLdHelper
 
-  def call(body, account, options = {})
+  def call(body, account, **options)
     @account = account
     @json    = Oj.load(body, mode: :strict)
     @options = options
diff --git a/app/services/authorize_follow_service.rb b/app/services/authorize_follow_service.rb
index b1bff8962..f47d488f1 100644
--- a/app/services/authorize_follow_service.rb
+++ b/app/services/authorize_follow_service.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 class AuthorizeFollowService < BaseService
-  def call(source_account, target_account, options = {})
+  def call(source_account, target_account, **options)
     if options[:skip_follow_request]
       follow_request = FollowRequest.new(account: source_account, target_account: target_account)
     else
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index 974c586f2..59531a76c 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -13,7 +13,7 @@ class PostStatusService < BaseService
   # @option [Doorkeeper::Application] :application
   # @option [String] :idempotency Optional idempotency key
   # @return [Status]
-  def call(account, text, in_reply_to = nil, options = {})
+  def call(account, text, in_reply_to = nil, **options)
     if options[:idempotency].present?
       existing_id = redis.get("idempotency:status:#{account.id}:#{options[:idempotency]}")
       return Status.find(existing_id) if existing_id
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index 60eff135e..30a9dd85e 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 class ProcessFeedService < BaseService
-  def call(body, account, options = {})
+  def call(body, account, **options)
     @options = options
 
     xml = Nokogiri::XML(body)
diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb
index 7789bd441..e164c03ab 100644
--- a/app/services/remove_status_service.rb
+++ b/app/services/remove_status_service.rb
@@ -3,7 +3,7 @@
 class RemoveStatusService < BaseService
   include StreamEntryRenderer
 
-  def call(status, options = {})
+  def call(status, **options)
     @payload      = Oj.dump(event: :delete, payload: status.id.to_s)
     @status       = status
     @account      = status.account
diff --git a/app/services/search_service.rb b/app/services/search_service.rb
index 1ed3f0032..85ad94463 100644
--- a/app/services/search_service.rb
+++ b/app/services/search_service.rb
@@ -10,7 +10,7 @@ class SearchService < BaseService
       if url_query?
         results.merge!(remote_resource_results) unless remote_resource.nil?
       elsif query.present?
-        results[:accounts] = AccountSearchService.new.call(query, limit, resolve, account)
+        results[:accounts] = AccountSearchService.new.call(query, limit, account, resolve: resolve)
         results[:hashtags] = Tag.search_for(query.gsub(/\A#/, ''), limit) unless query.start_with?('@')
       end
     end
diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb
index 5b37ba9ba..958b28cdc 100644
--- a/app/services/suspend_account_service.rb
+++ b/app/services/suspend_account_service.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 class SuspendAccountService < BaseService
-  def call(account, options = {})
+  def call(account, **options)
     @account = account
     @options = options