Reject existing Follow in addition to sending a Block (#9811)
Mastodon expects remote servers to remove follow relationships upon receiving a Block. However, the spec only evokes Block activities in a C2S context, never in a S2S context. This PR, in addition to federating the Block, explicitly sends a Reject for any affected follow relationship, which makes a bit more sense with regards to the spec.
This commit is contained in:
parent
75b1488cf4
commit
aeb124491d
2 changed files with 33 additions and 0 deletions
|
@ -20,6 +20,7 @@ class UnfollowService < BaseService
|
|||
|
||||
follow.destroy!
|
||||
create_notification(follow) unless @target_account.local?
|
||||
create_reject_notification(follow) if @target_account.local? && !@source_account.local?
|
||||
UnmergeWorker.perform_async(@target_account.id, @source_account.id)
|
||||
follow
|
||||
end
|
||||
|
@ -42,6 +43,12 @@ class UnfollowService < BaseService
|
|||
end
|
||||
end
|
||||
|
||||
def create_reject_notification(follow)
|
||||
# Rejecting an already-existing follow request
|
||||
return unless follow.account.activitypub?
|
||||
ActivityPub::DeliveryWorker.perform_async(build_reject_json(follow), follow.target_account_id, follow.account.inbox_url)
|
||||
end
|
||||
|
||||
def build_json(follow)
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
follow,
|
||||
|
@ -50,6 +57,14 @@ class UnfollowService < BaseService
|
|||
).to_json
|
||||
end
|
||||
|
||||
def build_reject_json(follow)
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
follow,
|
||||
serializer: ActivityPub::RejectFollowSerializer,
|
||||
adapter: ActivityPub::Adapter
|
||||
).to_json
|
||||
end
|
||||
|
||||
def build_xml(follow)
|
||||
OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unfollow_salmon(follow))
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue