Use atomUri in Undo activity of Announce (#5376)

This allows deletion of reblogs which delivered before with OStatus URI.
lolsob-rspec
unarist 2017-10-14 21:42:09 +09:00 committed by Eugen Rochko
parent b88cae6c6b
commit 69b74d26cd
3 changed files with 26 additions and 6 deletions

View File

@ -18,6 +18,7 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
def undo_announce
status = Status.find_by(uri: object_uri, account: @account)
status ||= Status.find_by(uri: @object['atomUri'], account: @account) if @object.is_a?(Hash) && @object['atomUri'].present?
if status.nil?
delete_later!(object_uri)

View File

@ -5,6 +5,7 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer
has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer, unless: :announce?
attribute :proper_uri, key: :object, if: :announce?
attribute :atom_uri, if: :announce?
def id
ActivityPub::TagManager.instance.activity_uri_for(object)
@ -34,6 +35,10 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer
ActivityPub::TagManager.instance.uri_for(object.proper)
end
def atom_uri
OStatus::TagManager.instance.uri_for(object)
end
def announce?
object.reblog?
end

View File

@ -25,9 +25,11 @@ RSpec.describe ActivityPub::Activity::Undo do
type: 'Announce',
actor: ActivityPub::TagManager.instance.uri_for(sender),
object: ActivityPub::TagManager.instance.uri_for(status),
atomUri: 'barbar',
}
end
context do
before do
Fabricate(:status, reblog: status, account: sender, uri: 'bar')
end
@ -38,6 +40,18 @@ RSpec.describe ActivityPub::Activity::Undo do
end
end
context 'with atomUri' do
before do
Fabricate(:status, reblog: status, account: sender, uri: 'barbar')
end
it 'deletes the reblog by atomUri' do
subject.perform
expect(sender.reblogged?(status)).to be false
end
end
end
context 'with Block' do
let(:recipient) { Fabricate(:account) }