Autofix Rubocop Style/RedundantBegin (#23703)
This commit is contained in:
@ -32,15 +32,13 @@ class AccountSearchService < BaseService
|
||||
|
||||
return @exact_match if defined?(@exact_match)
|
||||
|
||||
match = begin
|
||||
if options[:resolve]
|
||||
ResolveAccountService.new.call(query)
|
||||
elsif domain_is_local?
|
||||
Account.find_local(query_username)
|
||||
else
|
||||
Account.find_remote(query_username, query_domain)
|
||||
end
|
||||
end
|
||||
match = if options[:resolve]
|
||||
ResolveAccountService.new.call(query)
|
||||
elsif domain_is_local?
|
||||
Account.find_local(query_username)
|
||||
else
|
||||
Account.find_remote(query_username, query_domain)
|
||||
end
|
||||
|
||||
match = nil if !match.nil? && !account.nil? && options[:following] && !account.following?(match)
|
||||
|
||||
|
@ -22,14 +22,12 @@ class ActivityPub::FetchFeaturedTagsCollectionService < BaseService
|
||||
collection = fetch_collection(collection['first']) if collection['first'].present?
|
||||
|
||||
while collection.is_a?(Hash)
|
||||
items = begin
|
||||
case collection['type']
|
||||
when 'Collection', 'CollectionPage'
|
||||
collection['items']
|
||||
when 'OrderedCollection', 'OrderedCollectionPage'
|
||||
collection['orderedItems']
|
||||
end
|
||||
end
|
||||
items = case collection['type']
|
||||
when 'Collection', 'CollectionPage'
|
||||
collection['items']
|
||||
when 'OrderedCollection', 'OrderedCollectionPage'
|
||||
collection['orderedItems']
|
||||
end
|
||||
|
||||
break if items.blank?
|
||||
|
||||
|
@ -9,13 +9,11 @@ class ActivityPub::FetchRemoteStatusService < BaseService
|
||||
# Should be called when uri has already been checked for locality
|
||||
def call(uri, id: true, prefetched_body: nil, on_behalf_of: nil, expected_actor_uri: nil, request_id: nil)
|
||||
@request_id = request_id || "#{Time.now.utc.to_i}-status-#{uri}"
|
||||
@json = begin
|
||||
if prefetched_body.nil?
|
||||
fetch_resource(uri, id, on_behalf_of)
|
||||
else
|
||||
body_to_json(prefetched_body, compare_id: id ? uri : nil)
|
||||
end
|
||||
end
|
||||
@json = if prefetched_body.nil?
|
||||
fetch_resource(uri, id, on_behalf_of)
|
||||
else
|
||||
body_to_json(prefetched_body, compare_id: id ? uri : nil)
|
||||
end
|
||||
|
||||
return unless supported_context?
|
||||
|
||||
|
@ -69,16 +69,14 @@ class FetchLinkCardService < BaseService
|
||||
end
|
||||
|
||||
def parse_urls
|
||||
urls = begin
|
||||
if @status.local?
|
||||
@status.text.scan(URL_PATTERN).map { |array| Addressable::URI.parse(array[1]).normalize }
|
||||
else
|
||||
document = Nokogiri::HTML(@status.text)
|
||||
links = document.css('a')
|
||||
urls = if @status.local?
|
||||
@status.text.scan(URL_PATTERN).map { |array| Addressable::URI.parse(array[1]).normalize }
|
||||
else
|
||||
document = Nokogiri::HTML(@status.text)
|
||||
links = document.css('a')
|
||||
|
||||
links.filter_map { |a| Addressable::URI.parse(a['href']) unless skip_link?(a) }.filter_map(&:normalize)
|
||||
end
|
||||
end
|
||||
links.filter_map { |a| Addressable::URI.parse(a['href']) unless skip_link?(a) }.filter_map(&:normalize)
|
||||
end
|
||||
|
||||
urls.reject { |uri| bad_url?(uri) }.first
|
||||
end
|
||||
|
@ -28,13 +28,11 @@ class ProcessMentionsService < BaseService
|
||||
@status.text = @status.text.gsub(Account::MENTION_RE) do |match|
|
||||
username, domain = Regexp.last_match(1).split('@')
|
||||
|
||||
domain = begin
|
||||
if TagManager.instance.local_domain?(domain)
|
||||
nil
|
||||
else
|
||||
TagManager.instance.normalize_domain(domain)
|
||||
end
|
||||
end
|
||||
domain = if TagManager.instance.local_domain?(domain)
|
||||
nil
|
||||
else
|
||||
TagManager.instance.normalize_domain(domain)
|
||||
end
|
||||
|
||||
mentioned_account = Account.find_remote(username, domain)
|
||||
|
||||
|
@ -20,13 +20,11 @@ class ReblogService < BaseService
|
||||
|
||||
return reblog unless reblog.nil?
|
||||
|
||||
visibility = begin
|
||||
if reblogged_status.hidden?
|
||||
reblogged_status.visibility
|
||||
else
|
||||
options[:visibility] || account.user&.setting_default_privacy
|
||||
end
|
||||
end
|
||||
visibility = if reblogged_status.hidden?
|
||||
reblogged_status.visibility
|
||||
else
|
||||
options[:visibility] || account.user&.setting_default_privacy
|
||||
end
|
||||
|
||||
reblog = account.statuses.create!(reblog: reblogged_status, text: '', visibility: visibility, rate_limit: options[:with_rate_limit])
|
||||
|
||||
|
@ -71,13 +71,11 @@ class ResolveAccountService < BaseService
|
||||
@username, @domain = uri.strip.gsub(/\A@/, '').split('@')
|
||||
end
|
||||
|
||||
@domain = begin
|
||||
if TagManager.instance.local_domain?(@domain)
|
||||
nil
|
||||
else
|
||||
TagManager.instance.normalize_domain(@domain)
|
||||
end
|
||||
end
|
||||
@domain = if TagManager.instance.local_domain?(@domain)
|
||||
nil
|
||||
else
|
||||
TagManager.instance.normalize_domain(@domain)
|
||||
end
|
||||
|
||||
@uri = [@username, @domain].compact.join('@')
|
||||
end
|
||||
|
Reference in New Issue
Block a user