Merge tag 'v2.9.2' into instance_only_statuses
This commit is contained in:
@ -143,7 +143,7 @@ class ActivityPub::Activity
|
||||
|
||||
# If the boosted toot is embedded and it is a self-boost, handle it like a Create
|
||||
unless unsupported_object_type?
|
||||
actor_id = value_or_id(first_of_value(@object['attributedTo'])) || @account.uri
|
||||
actor_id = value_or_id(first_of_value(@object['attributedTo']))
|
||||
|
||||
if actor_id == @account.uri
|
||||
return ActivityPub::Activity.factory({ 'type' => 'Create', 'actor' => actor_id, 'object' => @object }, @account).perform
|
||||
|
@ -234,7 +234,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||
@account.polls.new(
|
||||
multiple: multiple,
|
||||
expires_at: expires_at,
|
||||
options: items.map { |item| item['name'].presence || item['content'] },
|
||||
options: items.map { |item| item['name'].presence || item['content'] }.compact,
|
||||
cached_tallies: items.map { |item| item.dig('replies', 'totalItems') || 0 }
|
||||
)
|
||||
end
|
||||
@ -370,7 +370,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||
end
|
||||
|
||||
def unsupported_media_type?(mime_type)
|
||||
mime_type.present? && !(MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES).include?(mime_type)
|
||||
mime_type.present? && !MediaAttachment.supported_mime_types.include?(mime_type)
|
||||
end
|
||||
|
||||
def supported_blurhash?(blurhash)
|
||||
@ -380,7 +380,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||
|
||||
def skip_download?
|
||||
return @skip_download if defined?(@skip_download)
|
||||
@skip_download ||= DomainBlock.find_by(domain: @account.domain)&.reject_media?
|
||||
@skip_download ||= DomainBlock.reject_media?(@account.domain)
|
||||
end
|
||||
|
||||
def reply_to_local?
|
||||
|
@ -45,7 +45,7 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
|
||||
rebloggers_ids = @status.reblogs.includes(:account).references(:account).merge(Account.local).pluck(:account_id)
|
||||
inboxes = Account.where(id: ::Follow.where(target_account_id: rebloggers_ids).select(:account_id)).inboxes - [@account.preferred_inbox_url]
|
||||
|
||||
ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url|
|
||||
ActivityPub::LowPriorityDeliveryWorker.push_bulk(inboxes) do |inbox_url|
|
||||
[payload, rebloggers_ids.first, inbox_url]
|
||||
end
|
||||
end
|
||||
@ -61,7 +61,12 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
|
||||
|
||||
def forward_for_reply
|
||||
return unless @json['signature'].present? && reply_to_local?
|
||||
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(@json), replied_to_status.account_id, [@account.preferred_inbox_url])
|
||||
|
||||
inboxes = replied_to_status.account.followers.inboxes - [@account.preferred_inbox_url]
|
||||
|
||||
ActivityPub::LowPriorityDeliveryWorker.push_bulk(inboxes) do |inbox_url|
|
||||
[payload, replied_to_status.account_id, inbox_url]
|
||||
end
|
||||
end
|
||||
|
||||
def delete_now!
|
||||
|
@ -23,7 +23,7 @@ class ActivityPub::Activity::Flag < ActivityPub::Activity
|
||||
private
|
||||
|
||||
def skip_reports?
|
||||
DomainBlock.find_by(domain: @account.domain)&.reject_reports?
|
||||
DomainBlock.reject_reports?(@account.domain)
|
||||
end
|
||||
|
||||
def object_uris
|
||||
|
@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::Activity::Follow < ActivityPub::Activity
|
||||
include Payloadable
|
||||
|
||||
def perform
|
||||
target_account = account_from_uri(object_uri)
|
||||
|
||||
@ -28,7 +30,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
||||
end
|
||||
|
||||
def reject_follow_request!(target_account)
|
||||
json = ActiveModelSerializers::SerializableResource.new(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), serializer: ActivityPub::RejectFollowSerializer, adapter: ActivityPub::Adapter).to_json
|
||||
json = Oj.dump(serialize_payload(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), ActivityPub::RejectFollowSerializer))
|
||||
ActivityPub::DeliveryWorker.perform_async(json, target_account.id, @account.inbox_url)
|
||||
end
|
||||
end
|
||||
|
@ -65,7 +65,14 @@ class ActivityPub::TagManager
|
||||
when 'unlisted', 'private'
|
||||
[account_followers_url(status.account)]
|
||||
when 'direct', 'limited'
|
||||
status.active_mentions.map { |mention| uri_for(mention.account) }
|
||||
if status.account.silenced?
|
||||
# Only notify followers if the account is locally silenced
|
||||
account_ids = status.active_mentions.pluck(:account_id)
|
||||
to = status.account.followers.where(id: account_ids).map { |account| uri_for(account) }
|
||||
to.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).map { |request| uri_for(request.account) })
|
||||
else
|
||||
status.active_mentions.map { |mention| uri_for(mention.account) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -86,7 +93,16 @@ class ActivityPub::TagManager
|
||||
cc << COLLECTIONS[:public]
|
||||
end
|
||||
|
||||
cc.concat(status.active_mentions.map { |mention| uri_for(mention.account) }) unless status.direct_visibility? || status.limited_visibility?
|
||||
unless status.direct_visibility? || status.limited_visibility?
|
||||
if status.account.silenced?
|
||||
# Only notify followers if the account is locally silenced
|
||||
account_ids = status.active_mentions.pluck(:account_id)
|
||||
cc.concat(status.account.followers.where(id: account_ids).map { |account| uri_for(account) })
|
||||
cc.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).map { |request| uri_for(request.account) })
|
||||
else
|
||||
cc.concat(status.active_mentions.map { |mention| uri_for(mention.account) })
|
||||
end
|
||||
end
|
||||
|
||||
cc
|
||||
end
|
||||
|
@ -148,7 +148,7 @@ class OStatus::Activity::Creation < OStatus::Activity::Base
|
||||
end
|
||||
|
||||
def save_media
|
||||
do_not_download = DomainBlock.find_by(domain: @account.domain)&.reject_media?
|
||||
do_not_download = DomainBlock.reject_media?(@account.domain)
|
||||
media_attachments = []
|
||||
|
||||
@xml.xpath('./xmlns:link[@rel="enclosure"]', xmlns: OStatus::TagManager::XMLNS).each do |link|
|
||||
@ -176,7 +176,7 @@ class OStatus::Activity::Creation < OStatus::Activity::Base
|
||||
end
|
||||
|
||||
def save_emojis(parent)
|
||||
do_not_download = DomainBlock.find_by(domain: parent.account.domain)&.reject_media?
|
||||
do_not_download = DomainBlock.reject_media?(parent.account.domain)
|
||||
|
||||
return if do_not_download
|
||||
|
||||
|
@ -19,6 +19,20 @@ class Sanitize
|
||||
node['class'] = class_list.join(' ')
|
||||
end
|
||||
|
||||
UNSUPPORTED_ELEMENTS_TRANSFORMER = lambda do |env|
|
||||
return unless %w(h1 h2 h3 h4 h5 h6 blockquote pre ul ol li).include?(env[:node_name])
|
||||
|
||||
case env[:node_name]
|
||||
when 'li'
|
||||
env[:node].traverse do |node|
|
||||
node.add_next_sibling('<br>') if node.next_sibling
|
||||
node.replace(node.children) unless node.text?
|
||||
end
|
||||
else
|
||||
env[:node].name = 'p'
|
||||
end
|
||||
end
|
||||
|
||||
MASTODON_STRICT ||= freeze_config(
|
||||
elements: %w(p br span a),
|
||||
|
||||
@ -40,6 +54,7 @@ class Sanitize
|
||||
|
||||
transformers: [
|
||||
CLASS_WHITELIST_TRANSFORMER,
|
||||
UNSUPPORTED_ELEMENTS_TRANSFORMER,
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -34,6 +34,7 @@ class UserSettingsDecorator
|
||||
user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network')
|
||||
user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
|
||||
user.settings['show_application'] = show_application_preference if change?('setting_show_application')
|
||||
user.settings['advanced_layout'] = advanced_layout_preference if change?('setting_advanced_layout')
|
||||
end
|
||||
|
||||
def merged_notification_emails
|
||||
@ -112,6 +113,10 @@ class UserSettingsDecorator
|
||||
boolean_cast_setting 'setting_aggregate_reblogs'
|
||||
end
|
||||
|
||||
def advanced_layout_preference
|
||||
boolean_cast_setting 'setting_advanced_layout'
|
||||
end
|
||||
|
||||
def boolean_cast_setting(key)
|
||||
ActiveModel::Type::Boolean.new.cast(settings[key])
|
||||
end
|
||||
|
Reference in New Issue
Block a user