Merge branch 'master' into feature-limited-visibility-bearcaps
This commit is contained in:
commit
98a2603dc1
855 changed files with 32564 additions and 10102 deletions
|
@ -74,7 +74,7 @@ class ActivityPub::Activity
|
|||
@object_uri ||= begin
|
||||
str = value_or_id(@object)
|
||||
|
||||
if str.start_with?('bear:')
|
||||
if str&.start_with?('bear:')
|
||||
Addressable::URI.parse(str).query_values['u']
|
||||
else
|
||||
str
|
||||
|
@ -118,13 +118,13 @@ class ActivityPub::Activity
|
|||
end
|
||||
|
||||
def notify_about_reblog(status)
|
||||
NotifyService.new.call(status.reblog.account, status)
|
||||
NotifyService.new.call(status.reblog.account, :reblog, status)
|
||||
end
|
||||
|
||||
def notify_about_mentions(status)
|
||||
status.active_mentions.includes(:account).each do |mention|
|
||||
next unless mention.account.local? && audience_includes?(mention.account)
|
||||
NotifyService.new.call(mention.account, mention)
|
||||
NotifyService.new.call(mention.account, :mention, mention)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
created_at: @object['published'],
|
||||
override_timestamps: @options[:override_timestamps],
|
||||
reply: @object['inReplyTo'].present?,
|
||||
sensitive: @object['sensitive'] || false,
|
||||
sensitive: @account.sensitized? || @object['sensitive'] || false,
|
||||
visibility: visibility_from_audience,
|
||||
thread: replied_to_status,
|
||||
conversation: conversation_from_context,
|
||||
|
@ -231,6 +231,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
emoji ||= CustomEmoji.new(domain: @account.domain, shortcode: shortcode, uri: uri)
|
||||
emoji.image_remote_url = image_url
|
||||
emoji.save
|
||||
rescue Seahorse::Client::NetworkingError
|
||||
nil
|
||||
end
|
||||
|
||||
def process_attachments
|
||||
|
@ -253,6 +255,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
media_attachment.save
|
||||
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError
|
||||
RedownloadMediaWorker.perform_in(rand(30..600).seconds, media_attachment.id)
|
||||
rescue Seahorse::Client::NetworkingError
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
|
|||
|
||||
def delete_person
|
||||
lock_or_return("delete_in_progress:#{@account.id}") do
|
||||
SuspendAccountService.new.call(@account, reserve_username: false)
|
||||
DeleteAccountService.new.call(@account, reserve_username: false, skip_activitypub: true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ class ActivityPub::Activity::Flag < ActivityPub::Activity
|
|||
def perform
|
||||
return if skip_reports?
|
||||
|
||||
target_accounts = object_uris.map { |uri| account_from_uri(uri) }.compact.select(&:local?)
|
||||
target_statuses_by_account = object_uris.map { |uri| status_from_uri(uri) }.compact.select(&:local?).group_by(&:account_id)
|
||||
target_accounts = object_uris.filter_map { |uri| account_from_uri(uri) }.select(&:local?)
|
||||
target_statuses_by_account = object_uris.filter_map { |uri| status_from_uri(uri) }.select(&:local?).group_by(&:account_id)
|
||||
|
||||
target_accounts.each do |target_account|
|
||||
target_statuses = target_statuses_by_account[target_account.id]
|
||||
|
|
|
@ -22,10 +22,10 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
|||
follow_request = FollowRequest.create!(account: @account, target_account: target_account, uri: @json['id'])
|
||||
|
||||
if target_account.locked? || @account.silenced?
|
||||
NotifyService.new.call(target_account, follow_request)
|
||||
NotifyService.new.call(target_account, :follow_request, follow_request)
|
||||
else
|
||||
AuthorizeFollowService.new.call(@account, target_account)
|
||||
NotifyService.new.call(target_account, ::Follow.find_by(account: @account, target_account: target_account))
|
||||
NotifyService.new.call(target_account, :follow, ::Follow.find_by(account: @account, target_account: target_account))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,6 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
|||
return if original_status.nil? || !original_status.account.local? || delete_arrived_first?(@json['id']) || @account.favourited?(original_status)
|
||||
|
||||
favourite = original_status.favourites.create!(account: @account)
|
||||
NotifyService.new.call(original_status.account, favourite)
|
||||
NotifyService.new.call(original_status.account, :favourite, favourite)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,9 @@ class ActivityPub::Activity::Move < ActivityPub::Activity
|
|||
|
||||
# Initiate a re-follow for each follower
|
||||
MoveWorker.perform_async(origin_account.id, target_account.id)
|
||||
rescue
|
||||
unmark_as_processing!
|
||||
raise
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -13,7 +13,7 @@ class ActivityPub::Adapter < ActiveModelSerializers::Adapter::Base
|
|||
moved_to: { 'movedTo' => { '@id' => 'as:movedTo', '@type' => '@id' } },
|
||||
also_known_as: { 'alsoKnownAs' => { '@id' => 'as:alsoKnownAs', '@type' => '@id' } },
|
||||
emoji: { 'toot' => 'http://joinmastodon.org/ns#', 'Emoji' => 'toot:Emoji' },
|
||||
featured: { 'toot' => 'http://joinmastodon.org/ns#', 'featured' => { '@id' => 'toot:featured', '@type' => '@id' } },
|
||||
featured: { 'toot' => 'http://joinmastodon.org/ns#', 'featured' => { '@id' => 'toot:featured', '@type' => '@id' }, 'featuredTags' => { '@id' => 'toot:featuredTags', '@type' => '@id' } },
|
||||
property_value: { 'schema' => 'http://schema.org#', 'PropertyValue' => 'schema:PropertyValue', 'value' => 'schema:value' },
|
||||
atom_uri: { 'ostatus' => 'http://ostatus.org#', 'atomUri' => 'ostatus:atomUri' },
|
||||
conversation: { 'ostatus' => 'http://ostatus.org#', 'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri', 'conversation' => 'ostatus:conversation' },
|
||||
|
@ -23,6 +23,7 @@ class ActivityPub::Adapter < ActiveModelSerializers::Adapter::Base
|
|||
discoverable: { 'toot' => 'http://joinmastodon.org/ns#', 'discoverable' => 'toot:discoverable' },
|
||||
voters_count: { 'toot' => 'http://joinmastodon.org/ns#', 'votersCount' => 'toot:votersCount' },
|
||||
olm: { 'toot' => 'http://joinmastodon.org/ns#', 'Device' => 'toot:Device', 'Ed25519Signature' => 'toot:Ed25519Signature', 'Ed25519Key' => 'toot:Ed25519Key', 'Curve25519Key' => 'toot:Curve25519Key', 'EncryptedMessage' => 'toot:EncryptedMessage', 'publicKeyBase64' => 'toot:publicKeyBase64', 'deviceId' => 'toot:deviceId', 'claim' => { '@type' => '@id', '@id' => 'toot:claim' }, 'fingerprintKey' => { '@type' => '@id', '@id' => 'toot:fingerprintKey' }, 'identityKey' => { '@type' => '@id', '@id' => 'toot:identityKey' }, 'devices' => { '@type' => '@id', '@id' => 'toot:devices' }, 'messageFranking' => 'toot:messageFranking', 'messageType' => 'toot:messageType', 'cipherText' => 'toot:cipherText' },
|
||||
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
|
||||
}.freeze
|
||||
|
||||
def self.default_key_transform
|
||||
|
|
|
@ -27,7 +27,7 @@ class ActivityPub::LinkedDataSignature
|
|||
document_hash = hash(@json.without('signature'))
|
||||
to_be_verified = options_hash + document_hash
|
||||
|
||||
if creator.keypair.public_key.verify(OpenSSL::Digest::SHA256.new, Base64.decode64(signature), to_be_verified)
|
||||
if creator.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), Base64.decode64(signature), to_be_verified)
|
||||
creator
|
||||
end
|
||||
end
|
||||
|
@ -44,7 +44,7 @@ class ActivityPub::LinkedDataSignature
|
|||
to_be_signed = options_hash + document_hash
|
||||
keypair = sign_with.present? ? OpenSSL::PKey::RSA.new(sign_with) : creator.keypair
|
||||
|
||||
signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest::SHA256.new, to_be_signed))
|
||||
signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest.new('SHA256'), to_be_signed))
|
||||
|
||||
@json.merge('signature' => options.merge('signatureValue' => signature))
|
||||
end
|
||||
|
|
|
@ -48,6 +48,10 @@ class ActivityPub::TagManager
|
|||
end
|
||||
end
|
||||
|
||||
def uri_for_username(username)
|
||||
account_url(username: username)
|
||||
end
|
||||
|
||||
def generate_uri_for(_target)
|
||||
URI.join(root_url, 'payloads', SecureRandom.uuid)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue