Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `.prettierignore`: Upstream added a line at the end of the file, while glitch-soc had its own extra lines. Took upstream's change. - `CONTRIBUTING.md`: We have our custom CONTRIBUTING.md quoting upstream. Upstream made changes. Ported upstream changes. - `app/controllers/application_controller.rb`: Upstream made code style changes in a method that is entirely replaced in glitch-soc. Ignored the change. - `app/models/account.rb`: Code style changes textually close to glitch-soc-specific changes. Ported upstream changes. - `lib/sanitize_ext/sanitize_config.rb`: Upstream code style changes. Ignored them.
This commit is contained in:
@ -153,6 +153,7 @@ class ActivityPub::Activity
|
||||
def fetch_remote_original_status
|
||||
if object_uri.start_with?('http')
|
||||
return if ActivityPub::TagManager.instance.local_uri?(object_uri)
|
||||
|
||||
ActivityPub::FetchRemoteStatusService.new.call(object_uri, id: true, on_behalf_of: @account.followers.local.first, request_id: @options[:request_id])
|
||||
elsif @object['url'].present?
|
||||
::FetchRemoteStatusService.new.call(@object['url'], request_id: @options[:request_id])
|
||||
|
@ -13,7 +13,7 @@ module ActivityPub::CaseTransform
|
||||
when Symbol then camel_lower(value.to_s).to_sym
|
||||
when String
|
||||
camel_lower_cache[value] ||= if value.start_with?('_:')
|
||||
'_:' + value.gsub(/\A_:/, '').underscore.camelize(:lower)
|
||||
"_:#{value.gsub(/\A_:/, '').underscore.camelize(:lower)}"
|
||||
else
|
||||
value.underscore.camelize(:lower)
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ class ActivityPub::LinkedDataSignature
|
||||
|
||||
def sign!(creator, sign_with: nil)
|
||||
options = {
|
||||
'type' => 'RsaSignature2017',
|
||||
'type' => 'RsaSignature2017',
|
||||
'creator' => ActivityPub::TagManager.instance.key_uri_for(creator),
|
||||
'created' => Time.now.utc.iso8601,
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ class ActivityPub::TagManager
|
||||
target.instance_actor? ? about_more_url(instance_actor: true) : short_account_url(target)
|
||||
when :note, :comment, :activity
|
||||
return activity_account_status_url(target.account, target) if target.reblog?
|
||||
|
||||
short_account_status_url(target.account, target)
|
||||
end
|
||||
end
|
||||
@ -38,6 +39,7 @@ class ActivityPub::TagManager
|
||||
target.instance_actor? ? instance_actor_url : account_url(target)
|
||||
when :note, :comment, :activity
|
||||
return activity_account_status_url(target.account, target) if target.reblog?
|
||||
|
||||
account_status_url(target.account, target)
|
||||
when :emoji
|
||||
emoji_url(target)
|
||||
|
@ -45,7 +45,7 @@ class Importer::BaseImporter
|
||||
# Remove documents from the index that no longer exist in the database
|
||||
def clean_up!
|
||||
index.scroll_batches do |documents|
|
||||
ids = documents.map { |doc| doc['_id'] }
|
||||
ids = documents.pluck('_id')
|
||||
existence_map = index.adapter.target.where(id: ids).pluck(:id).each_with_object({}) { |id, map| map[id.to_s] = true }
|
||||
tmp = ids.reject { |id| existence_map[id] }
|
||||
|
||||
|
@ -188,7 +188,7 @@ class LinkDetailsExtractor
|
||||
end
|
||||
|
||||
def language
|
||||
valid_locale_or_nil(structured_data&.language || opengraph_tag('og:locale') || document.xpath('//html').map { |element| element['lang'] }.first)
|
||||
valid_locale_or_nil(structured_data&.language || opengraph_tag('og:locale') || document.xpath('//html').pick('lang'))
|
||||
end
|
||||
|
||||
def icon
|
||||
@ -220,15 +220,15 @@ class LinkDetailsExtractor
|
||||
end
|
||||
|
||||
def link_tag(name)
|
||||
document.xpath("//link[@rel=\"#{name}\"]").map { |link| link['href'] }.first
|
||||
document.xpath("//link[@rel=\"#{name}\"]").pick('href')
|
||||
end
|
||||
|
||||
def opengraph_tag(name)
|
||||
document.xpath("//meta[@property=\"#{name}\" or @name=\"#{name}\"]").map { |meta| meta['content'] }.first
|
||||
document.xpath("//meta[@property=\"#{name}\" or @name=\"#{name}\"]").pick('content')
|
||||
end
|
||||
|
||||
def meta_tag(name)
|
||||
document.xpath("//meta[@name=\"#{name}\"]").map { |meta| meta['content'] }.first
|
||||
document.xpath("//meta[@name=\"#{name}\"]").pick('content')
|
||||
end
|
||||
|
||||
def structured_data
|
||||
|
@ -5,27 +5,27 @@ class OStatus::TagManager
|
||||
include RoutingHelper
|
||||
|
||||
VERBS = {
|
||||
post: 'http://activitystrea.ms/schema/1.0/post',
|
||||
share: 'http://activitystrea.ms/schema/1.0/share',
|
||||
favorite: 'http://activitystrea.ms/schema/1.0/favorite',
|
||||
unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite',
|
||||
delete: 'http://activitystrea.ms/schema/1.0/delete',
|
||||
follow: 'http://activitystrea.ms/schema/1.0/follow',
|
||||
post: 'http://activitystrea.ms/schema/1.0/post',
|
||||
share: 'http://activitystrea.ms/schema/1.0/share',
|
||||
favorite: 'http://activitystrea.ms/schema/1.0/favorite',
|
||||
unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite',
|
||||
delete: 'http://activitystrea.ms/schema/1.0/delete',
|
||||
follow: 'http://activitystrea.ms/schema/1.0/follow',
|
||||
request_friend: 'http://activitystrea.ms/schema/1.0/request-friend',
|
||||
authorize: 'http://activitystrea.ms/schema/1.0/authorize',
|
||||
reject: 'http://activitystrea.ms/schema/1.0/reject',
|
||||
unfollow: 'http://ostatus.org/schema/1.0/unfollow',
|
||||
block: 'http://mastodon.social/schema/1.0/block',
|
||||
unblock: 'http://mastodon.social/schema/1.0/unblock',
|
||||
authorize: 'http://activitystrea.ms/schema/1.0/authorize',
|
||||
reject: 'http://activitystrea.ms/schema/1.0/reject',
|
||||
unfollow: 'http://ostatus.org/schema/1.0/unfollow',
|
||||
block: 'http://mastodon.social/schema/1.0/block',
|
||||
unblock: 'http://mastodon.social/schema/1.0/unblock',
|
||||
}.freeze
|
||||
|
||||
TYPES = {
|
||||
activity: 'http://activitystrea.ms/schema/1.0/activity',
|
||||
note: 'http://activitystrea.ms/schema/1.0/note',
|
||||
comment: 'http://activitystrea.ms/schema/1.0/comment',
|
||||
person: 'http://activitystrea.ms/schema/1.0/person',
|
||||
activity: 'http://activitystrea.ms/schema/1.0/activity',
|
||||
note: 'http://activitystrea.ms/schema/1.0/note',
|
||||
comment: 'http://activitystrea.ms/schema/1.0/comment',
|
||||
person: 'http://activitystrea.ms/schema/1.0/person',
|
||||
collection: 'http://activitystrea.ms/schema/1.0/collection',
|
||||
group: 'http://activitystrea.ms/schema/1.0/group',
|
||||
group: 'http://activitystrea.ms/schema/1.0/group',
|
||||
}.freeze
|
||||
|
||||
COLLECTIONS = {
|
||||
|
@ -182,6 +182,7 @@ class Request
|
||||
|
||||
contents = truncated_body(limit)
|
||||
raise Mastodon::LengthValidationError if contents.bytesize > limit
|
||||
|
||||
contents
|
||||
end
|
||||
end
|
||||
|
@ -64,7 +64,7 @@ class RequestPool
|
||||
retries += 1
|
||||
retry
|
||||
end
|
||||
rescue StandardError
|
||||
rescue
|
||||
# If this connection raises errors of any kind, it's
|
||||
# better if it gets reaped as soon as possible
|
||||
|
||||
|
@ -35,6 +35,7 @@ module Settings
|
||||
|
||||
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
|
||||
|
||||
@ -55,6 +56,7 @@ module Settings
|
||||
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]
|
||||
|
@ -11,6 +11,7 @@ class StatusFilter
|
||||
|
||||
def filtered?
|
||||
return false if !account.nil? && account.id == status.account_id
|
||||
|
||||
blocked_by_policy? || (account_present? && filtered_status?) || silenced_account?
|
||||
end
|
||||
|
||||
|
@ -25,6 +25,7 @@ class TagManager
|
||||
def local_url?(url)
|
||||
uri = Addressable::URI.parse(url).normalize
|
||||
return false unless uri.host
|
||||
|
||||
domain = uri.host + (uri.port ? ":#{uri.port}" : '')
|
||||
|
||||
TagManager.instance.web_domain?(domain)
|
||||
|
@ -19,7 +19,7 @@ class ValidationErrorFormatter
|
||||
messages = errors.messages[attribute_name]
|
||||
|
||||
h[@aliases[attribute_name] || attribute_name] = attribute_errors.map.with_index do |error, index|
|
||||
{ error: 'ERR_' + error[:error].to_s.upcase, description: messages[index] }
|
||||
{ error: "ERR_#{error[:error].to_s.upcase}", description: messages[index] }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -57,6 +57,7 @@ class Webfinger
|
||||
if res.code == 200
|
||||
body = res.body_with_limit
|
||||
raise Webfinger::Error, "Request for #{@uri} returned empty response" if body.empty?
|
||||
|
||||
body
|
||||
elsif res.code == 404 && use_fallback
|
||||
body_from_host_meta
|
||||
|
Reference in New Issue
Block a user