Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - app/models/status.rb Resolved by taking both changes (not a real conflict, just changes too close to each other).
This commit is contained in:
@@ -129,4 +129,10 @@ class ActivityPub::Activity
|
||||
::FetchRemoteStatusService.new.call(@object['url'])
|
||||
end
|
||||
end
|
||||
|
||||
def lock_or_return(key, expire_after = 7.days.seconds)
|
||||
yield if redis.set(key, true, nx: true, ex: expire_after)
|
||||
ensure
|
||||
redis.del(key)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,8 +12,10 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
|
||||
private
|
||||
|
||||
def delete_person
|
||||
SuspendAccountService.new.call(@account)
|
||||
@account.destroy!
|
||||
lock_or_return("delete_in_progress:#{@account.id}") do
|
||||
SuspendAccountService.new.call(@account)
|
||||
@account.destroy!
|
||||
end
|
||||
end
|
||||
|
||||
def delete_note
|
||||
|
||||
@@ -21,7 +21,7 @@ class EntityCache
|
||||
end
|
||||
|
||||
unless uncached_ids.empty?
|
||||
uncached = CustomEmoji.where(shortcode: shortcodes, domain: domain, disabled: false).map { |item| [item.shortcode, item] }.to_h
|
||||
uncached = CustomEmoji.where(shortcode: shortcodes, domain: domain, disabled: false).each_with_object({}) { |item, h| h[item.shortcode] = item }
|
||||
uncached.each_value { |item| Rails.cache.write(to_key(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
|
||||
end
|
||||
|
||||
|
||||
@@ -40,7 +40,11 @@ class FeedManager
|
||||
end
|
||||
|
||||
def push_to_list(list, status)
|
||||
return false if status.reply? && status.in_reply_to_account_id != status.account_id
|
||||
if status.reply? && status.in_reply_to_account_id != status.account_id
|
||||
should_filter = status.in_reply_to_account_id != list.account_id
|
||||
should_filter &&= !ListAccount.where(list_id: list.id, account_id: status.in_reply_to_account_id).exists?
|
||||
return false if should_filter
|
||||
end
|
||||
return false unless add_to_feed(:list, list.id, status)
|
||||
trim(:list, list.id)
|
||||
PushUpdateWorker.perform_async(list.account_id, status.id, "timeline:list:#{list.id}") if push_update_required?("timeline:list:#{list.id}")
|
||||
|
||||
@@ -128,9 +128,9 @@ class Formatter
|
||||
return html if emojis.empty?
|
||||
|
||||
emoji_map = if animate
|
||||
emojis.map { |e| [e.shortcode, full_asset_url(e.image.url)] }.to_h
|
||||
emojis.each_with_object({}) { |e, h| h[e.shortcode] = full_asset_url(e.image.url) }
|
||||
else
|
||||
emojis.map { |e| [e.shortcode, full_asset_url(e.image.url(:static))] }.to_h
|
||||
emojis.each_with_object({}) { |e, h| h[e.shortcode] = full_asset_url(e.image.url(:static)) }
|
||||
end
|
||||
|
||||
i = -1
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
require 'ipaddr'
|
||||
require 'socket'
|
||||
require 'resolv'
|
||||
|
||||
class Request
|
||||
REQUEST_TARGET = '(request-target)'
|
||||
@@ -45,7 +46,7 @@ class Request
|
||||
end
|
||||
|
||||
begin
|
||||
yield response.extend(ClientLimit)
|
||||
yield response.extend(ClientLimit) if block_given?
|
||||
ensure
|
||||
http_client.close
|
||||
end
|
||||
@@ -94,7 +95,7 @@ class Request
|
||||
end
|
||||
|
||||
def timeout
|
||||
{ connect: 1, read: 10, write: 10 }
|
||||
{ connect: nil, read: 10, write: 10 }
|
||||
end
|
||||
|
||||
def http_client
|
||||
@@ -139,16 +140,29 @@ class Request
|
||||
class Socket < TCPSocket
|
||||
class << self
|
||||
def open(host, *args)
|
||||
return super host, *args if thru_hidden_service? host
|
||||
return super(host, *args) if thru_hidden_service?(host)
|
||||
|
||||
outer_e = nil
|
||||
Addrinfo.foreach(host, nil, nil, :SOCK_STREAM) do |address|
|
||||
begin
|
||||
raise Mastodon::HostValidationError if PrivateAddressCheck.private_address? IPAddr.new(address.ip_address)
|
||||
return super address.ip_address, *args
|
||||
rescue => e
|
||||
outer_e = e
|
||||
|
||||
Resolv::DNS.open do |dns|
|
||||
dns.timeouts = 1
|
||||
|
||||
addresses = dns.getaddresses(host).take(2)
|
||||
time_slot = 10.0 / addresses.size
|
||||
|
||||
addresses.each do |address|
|
||||
begin
|
||||
raise Mastodon::HostValidationError if PrivateAddressCheck.private_address?(IPAddr.new(address.to_s))
|
||||
|
||||
::Timeout.timeout(time_slot, HTTP::TimeoutError) do
|
||||
return super(address.to_s, *args)
|
||||
end
|
||||
rescue => e
|
||||
outer_e = e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
raise outer_e if outer_e
|
||||
end
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ module Settings
|
||||
|
||||
def all_as_records
|
||||
vars = thing_scoped
|
||||
records = vars.map { |r| [r.var, r] }.to_h
|
||||
records = vars.each_with_object({}) { |r, h| h[r.var] = r }
|
||||
|
||||
Setting.default_settings.each do |key, default_value|
|
||||
next if records.key?(key) || default_value.is_a?(Hash)
|
||||
@@ -66,7 +66,7 @@ module Settings
|
||||
|
||||
class << self
|
||||
def default_settings
|
||||
defaulting = DEFAULTING_TO_UNSCOPED.map { |k| [k, Setting[k]] }.to_h
|
||||
defaulting = DEFAULTING_TO_UNSCOPED.each_with_object({}) { |k, h| h[k] = Setting[k] }
|
||||
Setting.default_settings.merge!(defaulting)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user