Merge commit '7d9b209fe84b00eff348ea9d54905cbfffa79788' into glitch-soc/merge-upstream

Conflicts:
- `app/models/form/admin_settings.rb`:
  Upstream changed code style change, including on a line modified by glitch-soc.
  Kept glitch-soc's line but with the code style change applied.
This commit is contained in:
Claire committed 2023-12-21 19:31:12 +01:00
commit 30ee7339d3
33 files changed
+591 -485

No files matched your search

@@ -60,12 +60,6 @@ module Account::Interactions
end
end
def domain_blocking_map(target_account_ids, account_id)
accounts_map = Account.where(id: target_account_ids).select('id, domain').each_with_object({}) { |a, h| h[a.id] = a.domain }
blocked_domains = domain_blocking_map_by_domain(accounts_map.values.compact, account_id)
accounts_map.reduce({}) { |h, (id, domain)| h.merge(id => blocked_domains[domain]) }
end
def domain_blocking_map_by_domain(target_domains, account_id)
follow_mapping(AccountDomainBlock.where(account_id: account_id, domain: target_domains), :domain)
end
@@ -10,7 +10,7 @@ module RelationshipCacheable
private
def remove_relationship_cache
Rails.cache.delete("relationship:#{account_id}:#{target_account_id}")
Rails.cache.delete("relationship:#{target_account_id}:#{account_id}")
Rails.cache.delete(['relationship', account_id, target_account_id])
Rails.cache.delete(['relationship', target_account_id, account_id])
end
end
+8 -8
View File
@@ -7,7 +7,7 @@ module Remotable
def remotable_attachment(attachment_name, limit, suppress_errors: true, download_on_assign: true, attribute_name: nil)
attribute_name ||= :"#{attachment_name}_remote_url"
define_method("download_#{attachment_name}!") do |url = nil|
define_method(:"download_#{attachment_name}!") do |url = nil|
url ||= self[attribute_name]
return if url.blank?
@@ -24,29 +24,29 @@ module Remotable
Request.new(:get, url).perform do |response|
raise Mastodon::UnexpectedResponseError, response unless (200...300).cover?(response.code)
public_send("#{attachment_name}=", ResponseWithLimit.new(response, limit))
public_send(:"#{attachment_name}=", ResponseWithLimit.new(response, limit))
end
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError => e
Rails.logger.debug { "Error fetching remote #{attachment_name}: #{e}" }
public_send("#{attachment_name}=", nil) if public_send("#{attachment_name}_file_name").present?
public_send(:"#{attachment_name}=", nil) if public_send(:"#{attachment_name}_file_name").present?
raise e unless suppress_errors
rescue Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, Paperclip::Error, Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => e
Rails.logger.debug { "Error fetching remote #{attachment_name}: #{e}" }
public_send("#{attachment_name}=", nil) if public_send("#{attachment_name}_file_name").present?
public_send(:"#{attachment_name}=", nil) if public_send(:"#{attachment_name}_file_name").present?
end
nil
end
define_method("#{attribute_name}=") do |url|
return if self[attribute_name] == url && public_send("#{attachment_name}_file_name").present?
define_method(:"#{attribute_name}=") do |url|
return if self[attribute_name] == url && public_send(:"#{attachment_name}_file_name").present?
self[attribute_name] = url if has_attribute?(attribute_name)
public_send("download_#{attachment_name}!", url) if download_on_assign
public_send(:"download_#{attachment_name}!", url) if download_on_assign
end
alias_method("reset_#{attachment_name}!", "download_#{attachment_name}!")
alias_method(:"reset_#{attachment_name}!", "download_#{attachment_name}!")
end
end
end