From e3d96a9bc62f57d60dc21906b4b803e346b0a738 Mon Sep 17 00:00:00 2001 From: Starfall Date: Thu, 23 Jul 2020 16:25:17 -0500 Subject: Revert "[Federation] Dereference object URIs in Create and Update messages" This reverts commit 57c448d9e2d71be819552092dd4688488152776c. Implementation was merged upstream; removing the duplicate change. --- app/lib/activitypub/activity.rb | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'app/lib/activitypub/activity.rb') diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index d6e17ba5d..0ce279d28 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -157,38 +157,6 @@ class ActivityPub::Activity fetch_remote_original_status end - def dereference_object! - return unless @object.is_a?(String) && object_uri.start_with?('https://', 'http://') - return if ActivityPub::TagManager.instance.local_uri?(object_uri) - - object = fetch_resource(@object, true, signed_fetch_account) - return unless object.present? && object.is_a?(Hash) && supported_context?(object) && equals_or_includes_any?(object['type'], SUPPORTED_TYPES + CONVERTED_TYPES) - - actor_id = value_or_id(first_of_value(object['attributedTo'])) - return if actor_id.nil? || object['id'].nil? - return unless Addressable::URI.parse(object['id']).normalized_host.casecmp(Addressable::URI.parse(actor_id).normalized_host).zero? - - @object = object - end - - def signed_fetch_account - first_mentioned_local_account || first_local_follower - end - - def first_mentioned_local_account - audience = (as_array(@json['to']) + as_array(@json['cc'])).uniq - local_usernames = audience.select { |uri| ActivityPub::TagManager.instance.local_uri?(uri) } - .map { |uri| ActivityPub::TagManager.instance.uri_to_local_id(uri, :username) } - - return if local_usernames.empty? - - Account.local.where(username: local_usernames).first - end - - def first_local_follower - @account.followers.local.first - end - def follow_request_from_object @follow_request ||= FollowRequest.find_by(target_account: @account, uri: object_uri) unless object_uri.nil? end -- cgit