Use atomUri in Undo activity of Announce (#5376)
This allows deletion of reblogs which delivered before with OStatus URI.
This commit is contained in:
parent
ae716a12e1
commit
8125fdc19f
|
@ -17,7 +17,8 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
|
||||||
private
|
private
|
||||||
|
|
||||||
def undo_announce
|
def undo_announce
|
||||||
status = Status.find_by(uri: object_uri, account: @account)
|
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?
|
if status.nil?
|
||||||
delete_later!(object_uri)
|
delete_later!(object_uri)
|
||||||
|
|
|
@ -5,6 +5,7 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer, unless: :announce?
|
has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer, unless: :announce?
|
||||||
attribute :proper_uri, key: :object, if: :announce?
|
attribute :proper_uri, key: :object, if: :announce?
|
||||||
|
attribute :atom_uri, if: :announce?
|
||||||
|
|
||||||
def id
|
def id
|
||||||
ActivityPub::TagManager.instance.activity_uri_for(object)
|
ActivityPub::TagManager.instance.activity_uri_for(object)
|
||||||
|
@ -34,6 +35,10 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer
|
||||||
ActivityPub::TagManager.instance.uri_for(object.proper)
|
ActivityPub::TagManager.instance.uri_for(object.proper)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def atom_uri
|
||||||
|
OStatus::TagManager.instance.uri_for(object)
|
||||||
|
end
|
||||||
|
|
||||||
def announce?
|
def announce?
|
||||||
object.reblog?
|
object.reblog?
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,16 +25,30 @@ RSpec.describe ActivityPub::Activity::Undo do
|
||||||
type: 'Announce',
|
type: 'Announce',
|
||||||
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
object: ActivityPub::TagManager.instance.uri_for(status),
|
object: ActivityPub::TagManager.instance.uri_for(status),
|
||||||
|
atomUri: 'barbar',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
context do
|
||||||
Fabricate(:status, reblog: status, account: sender, uri: 'bar')
|
before do
|
||||||
|
Fabricate(:status, reblog: status, account: sender, uri: 'bar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'deletes the reblog' do
|
||||||
|
subject.perform
|
||||||
|
expect(sender.reblogged?(status)).to be false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes the reblog' do
|
context 'with atomUri' do
|
||||||
subject.perform
|
before do
|
||||||
expect(sender.reblogged?(status)).to be false
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue