summaryrefslogtreecommitdiffstats
path: root/app/lib/activitypub/activity.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2020-08-30 12:34:20 +0200
committerGitHub <noreply@github.com>2020-08-30 12:34:20 +0200
commit52157fdcba0837c782edbfd240be07cabc551de9 (patch)
treef3c7263b6dd9cc2c1fb5ff83b84654b8f6800c3a /app/lib/activitypub/activity.rb
parentce8f33dd2f0fddf4bb30cbcdece8ed102838a0fb (diff)
Add support for dereferencing objects through bearcaps (#14683)
Diffstat (limited to 'app/lib/activitypub/activity.rb')
-rw-r--r--app/lib/activitypub/activity.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb
index a379a7ef431..94aee7939fc 100644
--- a/app/lib/activitypub/activity.rb
+++ b/app/lib/activitypub/activity.rb
@@ -71,7 +71,15 @@ class ActivityPub::Activity
end
def object_uri
- @object_uri ||= value_or_id(@object)
+ @object_uri ||= begin
+ str = value_or_id(@object)
+
+ if str.start_with?('bear:')
+ Addressable::URI.parse(str).query_values['u']
+ else
+ str
+ end
+ end
end
def unsupported_object_type?
@@ -159,12 +167,10 @@ class ActivityPub::Activity
def dereference_object!
return unless @object.is_a?(String)
- return if invalid_origin?(@object)
- object = fetch_resource(@object, true, signed_fetch_account)
- return unless object.present? && object.is_a?(Hash) && supported_context?(object)
+ dereferencer = ActivityPub::Dereferencer.new(@object, permitted_origin: @account.uri, signature_account: signed_fetch_account)
- @object = object
+ @object = dereferencer.object unless dereferencer.object.nil?
end
def signed_fetch_account