Merge remote-tracking branch 'parent/main' into upstream-20240112
This commit is contained in:
commit
e65fb9fb51
333 changed files with 2661 additions and 1461 deletions
|
@ -10,7 +10,7 @@ class ContentSecurityPolicy
|
|||
end
|
||||
|
||||
def media_hosts
|
||||
[assets_host, cdn_host_value].compact
|
||||
[assets_host, cdn_host_value, paperclip_root_url].compact
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -23,6 +23,15 @@ class ContentSecurityPolicy
|
|||
s3_alias_host || s3_cloudfront_host || azure_alias_host || s3_hostname_host
|
||||
end
|
||||
|
||||
def paperclip_root_url
|
||||
root_url = ENV.fetch('PAPERCLIP_ROOT_URL', nil)
|
||||
return if root_url.blank?
|
||||
|
||||
(Addressable::URI.parse(assets_host) + root_url).tap do |uri|
|
||||
uri.path += '/' unless uri.path.blank? || uri.path.end_with?('/')
|
||||
end.to_s
|
||||
end
|
||||
|
||||
def url_from_base_host
|
||||
host_to_url(base_host)
|
||||
end
|
||||
|
|
|
@ -69,16 +69,6 @@ class EmojiFormatter
|
|||
@emoji_map ||= custom_emojis.each_with_object({}) { |e, h| h[e.shortcode] = [full_asset_url(e.image.url), full_asset_url(e.image.url(:static))] }
|
||||
end
|
||||
|
||||
def count_tag_nesting(tag)
|
||||
if tag[1] == '/'
|
||||
-1
|
||||
elsif tag[-2] == '/'
|
||||
0
|
||||
else
|
||||
1
|
||||
end
|
||||
end
|
||||
|
||||
def tag_for_emoji(shortcode, emoji)
|
||||
return content_tag(:span, ":#{shortcode}:", translate: 'no') if raw_shortcode?
|
||||
|
||||
|
|
|
@ -409,7 +409,7 @@ class FeedManager
|
|||
# @param [Integer] receiver_id
|
||||
# @param [Hash] crutches
|
||||
# @return [Boolean]
|
||||
def filter_from_home?(status, receiver_id, crutches, timeline_type = :home, stl_home: false) # rubocop:disable Metrics/PerceivedComplexity
|
||||
def filter_from_home?(status, receiver_id, crutches, timeline_type = :home, stl_home: false) # rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize
|
||||
return false if receiver_id == status.account_id
|
||||
return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?) && !(timeline_type == :home && status.limited_visibility?)
|
||||
return true if (timeline_type != :list || stl_home) && (crutches[:exclusive_list_users][status.account_id].present? || crutches[:exclusive_antenna_users][status.account_id].present?)
|
||||
|
@ -588,7 +588,7 @@ class FeedManager
|
|||
# @param [Integer] receiver_id
|
||||
# @param [Array<Status>] statuses
|
||||
# @return [Hash]
|
||||
def build_crutches(receiver_id, statuses)
|
||||
def build_crutches(receiver_id, statuses) # rubocop:disable Metrics/AbcSize
|
||||
crutches = {}
|
||||
|
||||
crutches[:active_mentions] = crutches_active_mentions(statuses)
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Settings
|
||||
class ScopedSettings
|
||||
DEFAULTING_TO_UNSCOPED = %w(
|
||||
theme
|
||||
noindex
|
||||
).freeze
|
||||
|
||||
def initialize(object)
|
||||
@object = object
|
||||
end
|
||||
|
||||
def method_missing(method, *args)
|
||||
method_name = method.to_s
|
||||
# set a value for a variable
|
||||
if method_name[-1] == '='
|
||||
var_name = method_name.sub('=', '')
|
||||
value = args.first
|
||||
self[var_name] = value
|
||||
else
|
||||
# retrieve a value
|
||||
self[method_name]
|
||||
end
|
||||
end
|
||||
|
||||
def respond_to_missing?(*)
|
||||
true
|
||||
end
|
||||
|
||||
def all_as_records
|
||||
vars = thing_scoped
|
||||
records = vars.index_by(&:var)
|
||||
|
||||
Setting.default_settings.each do |key, default_value|
|
||||
next if records.key?(key) || default_value.is_a?(Hash)
|
||||
|
||||
records[key] = Setting.new(var: key, value: default_value)
|
||||
end
|
||||
|
||||
records
|
||||
end
|
||||
|
||||
def []=(key, value)
|
||||
key = key.to_s
|
||||
record = thing_scoped.find_or_initialize_by(var: key)
|
||||
record.update!(value: value)
|
||||
|
||||
Rails.cache.write(Setting.cache_key(key, @object), value)
|
||||
end
|
||||
|
||||
def [](key)
|
||||
Rails.cache.fetch(Setting.cache_key(key, @object)) do
|
||||
db_val = thing_scoped.find_by(var: key.to_s)
|
||||
if db_val
|
||||
default_value = ScopedSettings.default_settings[key]
|
||||
return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
|
||||
|
||||
db_val.value
|
||||
else
|
||||
ScopedSettings.default_settings[key]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
def default_settings
|
||||
defaulting = DEFAULTING_TO_UNSCOPED.index_with { |k| Setting[k] }
|
||||
Setting.default_settings.merge!(defaulting)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def thing_scoped
|
||||
Setting.unscoped.where(thing_type: @object.class.base_class.to_s, thing_id: @object.id)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -43,7 +43,7 @@ class StatusCacheHydrator
|
|||
end
|
||||
end
|
||||
|
||||
def hydrate_reblog_payload(empty_payload, account_id, account)
|
||||
def hydrate_reblog_payload(empty_payload, account_id, account) # rubocop:disable Metrics/AbcSize
|
||||
empty_payload.tap do |payload|
|
||||
payload[:muted] = false
|
||||
payload[:bookmarked] = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue