mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-15 19:33:32 +00:00
Allow Accept/Reject with a non-embedded object (#12199)
Some ActivityPub servers refuse to embed remote objects into their own output. This is because they are not the authoritative source for these objects, and as such embedding them is always a waste of space. The follow request and follow models contain a URI, so this can be used to match them.
This commit is contained in:
parent
bd684e25d9
commit
d2919f7e94
|
@ -153,6 +153,14 @@ class ActivityPub::Activity
|
||||||
fetch_remote_original_status
|
fetch_remote_original_status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def follow_request_from_object
|
||||||
|
@follow_request ||= FollowRequest.find_by(target_account: @account, uri: object_uri) unless object_uri.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def follow_from_object
|
||||||
|
@follow ||= Follow.find_by(target_account: @account, uri: object_uri) unless object_uri.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_remote_original_status
|
def fetch_remote_original_status
|
||||||
if object_uri.start_with?('http')
|
if object_uri.start_with?('http')
|
||||||
return if ActivityPub::TagManager.instance.local_uri?(object_uri)
|
return if ActivityPub::TagManager.instance.local_uri?(object_uri)
|
||||||
|
|
|
@ -2,17 +2,18 @@
|
||||||
|
|
||||||
class ActivityPub::Activity::Accept < ActivityPub::Activity
|
class ActivityPub::Activity::Accept < ActivityPub::Activity
|
||||||
def perform
|
def perform
|
||||||
|
return accept_follow_for_relay if relay_follow?
|
||||||
|
return follow_request_from_object.authorize! unless follow_request_from_object.nil?
|
||||||
|
|
||||||
case @object['type']
|
case @object['type']
|
||||||
when 'Follow'
|
when 'Follow'
|
||||||
accept_follow
|
accept_embedded_follow
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def accept_follow
|
def accept_embedded_follow
|
||||||
return accept_follow_for_relay if relay_follow?
|
|
||||||
|
|
||||||
target_account = account_from_uri(target_uri)
|
target_account = account_from_uri(target_uri)
|
||||||
|
|
||||||
return if target_account.nil? || !target_account.local?
|
return if target_account.nil? || !target_account.local?
|
||||||
|
|
|
@ -2,17 +2,19 @@
|
||||||
|
|
||||||
class ActivityPub::Activity::Reject < ActivityPub::Activity
|
class ActivityPub::Activity::Reject < ActivityPub::Activity
|
||||||
def perform
|
def perform
|
||||||
|
return reject_follow_for_relay if relay_follow?
|
||||||
|
return follow_request_from_object.reject! unless follow_request_from_object.nil?
|
||||||
|
return UnfollowService.new.call(follow_from_object.target_account, @account) unless follow_from_object.nil?
|
||||||
|
|
||||||
case @object['type']
|
case @object['type']
|
||||||
when 'Follow'
|
when 'Follow'
|
||||||
reject_follow
|
reject_embedded_follow
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def reject_follow
|
def reject_embedded_follow
|
||||||
return reject_follow_for_relay if relay_follow?
|
|
||||||
|
|
||||||
target_account = account_from_uri(target_uri)
|
target_account = account_from_uri(target_uri)
|
||||||
|
|
||||||
return if target_account.nil? || !target_account.local?
|
return if target_account.nil? || !target_account.local?
|
||||||
|
|
Loading…
Reference in a new issue