Merge branch 'master' into glitch-soc/master
Conflicts: app/models/account.rb app/views/accounts/_header.html.haml
This commit is contained in:
@ -86,6 +86,8 @@ class ActivityPub::TagManager
|
||||
end
|
||||
|
||||
def local_uri?(uri)
|
||||
return false if uri.nil?
|
||||
|
||||
uri = Addressable::URI.parse(uri)
|
||||
host = uri.normalized_host
|
||||
host = "#{host}:#{uri.port}" if uri.port
|
||||
@ -99,6 +101,8 @@ class ActivityPub::TagManager
|
||||
end
|
||||
|
||||
def uri_to_resource(uri, klass)
|
||||
return if uri.nil?
|
||||
|
||||
if local_uri?(uri)
|
||||
case klass.name
|
||||
when 'Account'
|
||||
|
@ -67,9 +67,17 @@ class Formatter
|
||||
html.html_safe # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def format_field(account, str)
|
||||
def format_display_name(account, **options)
|
||||
html = encode(account.display_name.presence || account.username)
|
||||
html = encode_custom_emojis(html, account.emojis) if options[:custom_emojify]
|
||||
html.html_safe # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def format_field(account, str, **options)
|
||||
return reformat(str).html_safe unless account.local? # rubocop:disable Rails/OutputSafety
|
||||
encode_and_link_urls(str, me: true).html_safe # rubocop:disable Rails/OutputSafety
|
||||
html = encode_and_link_urls(str, me: true)
|
||||
html = encode_custom_emojis(html, account.emojis) if options[:custom_emojify]
|
||||
html.html_safe # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def linkify(text)
|
||||
|
@ -46,7 +46,8 @@ class OStatus::Activity::Creation < OStatus::Activity::Base
|
||||
visibility: visibility_scope,
|
||||
conversation: find_or_create_conversation,
|
||||
thread: thread? ? find_status(thread.first) || find_activitypub_status(thread.first, thread.second) : nil,
|
||||
media_attachment_ids: media_attachments.map(&:id)
|
||||
media_attachment_ids: media_attachments.map(&:id),
|
||||
sensitive: sensitive?
|
||||
)
|
||||
|
||||
save_mentions(status)
|
||||
@ -105,6 +106,11 @@ class OStatus::Activity::Creation < OStatus::Activity::Base
|
||||
|
||||
private
|
||||
|
||||
def sensitive?
|
||||
# OStatus-specific convention (not standard)
|
||||
@xml.xpath('./xmlns:category', xmlns: OStatus::TagManager::XMLNS).any? { |category| category['term'] == 'nsfw' }
|
||||
end
|
||||
|
||||
def find_or_create_conversation
|
||||
uri = @xml.at_xpath('./ostatus:conversation', ostatus: OStatus::TagManager::OS_XMLNS)&.attribute('ref')&.content
|
||||
return if uri.nil?
|
||||
|
@ -368,6 +368,7 @@ class OStatus::AtomSerializer
|
||||
append_element(entry, 'link', nil, rel: :enclosure, type: media.file_content_type, length: media.file_file_size, href: full_asset_url(media.file.url(:original, false)))
|
||||
end
|
||||
|
||||
append_element(entry, 'category', nil, term: 'nsfw') if status.sensitive? && status.media_attachments.any?
|
||||
append_element(entry, 'mastodon:scope', status.visibility)
|
||||
|
||||
status.emojis.each do |emoji|
|
||||
|
@ -51,7 +51,7 @@ class Request
|
||||
end
|
||||
|
||||
def headers
|
||||
(@account ? @headers.merge('Signature' => signature) : @headers).without(REQUEST_TARGET)
|
||||
(@account ? @headers.merge('Signature' => signature) : @headers).reverse_merge('Accept-Encoding' => 'gzip').without(REQUEST_TARGET)
|
||||
end
|
||||
|
||||
private
|
||||
@ -100,7 +100,7 @@ class Request
|
||||
end
|
||||
|
||||
def http_client
|
||||
@http_client ||= HTTP.timeout(:per_operation, timeout).follow(max_hops: 2)
|
||||
@http_client ||= HTTP.use(:auto_inflate).timeout(:per_operation, timeout).follow(max_hops: 2)
|
||||
end
|
||||
|
||||
def use_proxy?
|
||||
|
Reference in New Issue
Block a user