Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SuspendAccountService < BaseService
|
||||
def call(account, options = {})
|
||||
def call(account, **options)
|
||||
@account = account
|
||||
@options = options
|
||||
|
||||
|
Reference in New Issue
Block a user