mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
Enable authorized fetch for individual users who block remote domains
This commit is contained in:
parent
c7c727994a
commit
1c2b8e3500
|
@ -54,4 +54,8 @@ module AccountOwnedConcern
|
|||
expires_in(3.minutes, public: true)
|
||||
forbidden
|
||||
end
|
||||
|
||||
def authorized_fetch_mode?
|
||||
super || @account.domain_blocks.exists?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,20 +11,20 @@ module Payloadable
|
|||
# @option options [Boolean] :always_sign
|
||||
# @return [Hash]
|
||||
def serialize_payload(record, serializer, options = {})
|
||||
signer = options.delete(:signer)
|
||||
@signer = options.delete(:signer)
|
||||
sign_with = options.delete(:sign_with)
|
||||
always_sign = options.delete(:always_sign)
|
||||
payload = ActiveModelSerializers::SerializableResource.new(record, options.merge(serializer: serializer, adapter: ActivityPub::Adapter)).as_json
|
||||
object = record.respond_to?(:virtual_object) ? record.virtual_object : record
|
||||
|
||||
if (object.respond_to?(:sign?) && object.sign?) && signer && (always_sign || signing_enabled?)
|
||||
ActivityPub::LinkedDataSignature.new(payload).sign!(signer, sign_with: sign_with)
|
||||
if (object.respond_to?(:sign?) && object.sign?) && @signer && (always_sign || signing_enabled?)
|
||||
ActivityPub::LinkedDataSignature.new(payload).sign!(@signer, sign_with: sign_with)
|
||||
else
|
||||
payload
|
||||
end
|
||||
end
|
||||
|
||||
def signing_enabled?
|
||||
!authorized_fetch_mode?
|
||||
!authorized_fetch_mode? && !@signer.domain_blocks.exists?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user