mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
Drop support for atomUri
and inReplyToAtomUri
This commit is contained in:
parent
00cb4a0313
commit
d3e0eb8c00
|
@ -15,8 +15,7 @@ module ContextHelper
|
||||||
emoji: { 'toot' => 'http://joinmastodon.org/ns#', 'Emoji' => 'toot:Emoji' },
|
emoji: { 'toot' => 'http://joinmastodon.org/ns#', 'Emoji' => 'toot:Emoji' },
|
||||||
featured: { 'toot' => 'http://joinmastodon.org/ns#', 'featured' => { '@id' => 'toot:featured', '@type' => '@id' }, 'featuredTags' => { '@id' => 'toot:featuredTags', '@type' => '@id' } },
|
featured: { 'toot' => 'http://joinmastodon.org/ns#', 'featured' => { '@id' => 'toot:featured', '@type' => '@id' }, 'featuredTags' => { '@id' => 'toot:featuredTags', '@type' => '@id' } },
|
||||||
property_value: { 'schema' => 'http://schema.org#', 'PropertyValue' => 'schema:PropertyValue', 'value' => 'schema:value' },
|
property_value: { 'schema' => 'http://schema.org#', 'PropertyValue' => 'schema:PropertyValue', 'value' => 'schema:value' },
|
||||||
atom_uri: { 'ostatus' => 'http://ostatus.org#', 'atomUri' => 'ostatus:atomUri' },
|
conversation: { 'ostatus' => 'http://ostatus.org#', 'conversation' => 'ostatus:conversation' },
|
||||||
conversation: { 'ostatus' => 'http://ostatus.org#', 'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri', 'conversation' => 'ostatus:conversation' },
|
|
||||||
focal_point: { 'toot' => 'http://joinmastodon.org/ns#', 'focalPoint' => { '@container' => '@list', '@id' => 'toot:focalPoint' } },
|
focal_point: { 'toot' => 'http://joinmastodon.org/ns#', 'focalPoint' => { '@container' => '@list', '@id' => 'toot:focalPoint' } },
|
||||||
blurhash: { 'toot' => 'http://joinmastodon.org/ns#', 'blurhash' => 'toot:blurhash' },
|
blurhash: { 'toot' => 'http://joinmastodon.org/ns#', 'blurhash' => 'toot:blurhash' },
|
||||||
discoverable: { 'toot' => 'http://joinmastodon.org/ns#', 'discoverable' => 'toot:discoverable' },
|
discoverable: { 'toot' => 'http://joinmastodon.org/ns#', 'discoverable' => 'toot:discoverable' },
|
||||||
|
|
|
@ -102,8 +102,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_existing_status
|
def find_existing_status
|
||||||
status = status_from_uri(object_uri)
|
status = status_from_uri(object_uri)
|
||||||
status ||= Status.find_by(uri: @object['atomUri']) if @object['atomUri'].present?
|
|
||||||
status if status&.account_id == @account.id
|
status if status&.account_id == @account.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -362,8 +361,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
if in_reply_to_uri.blank?
|
if in_reply_to_uri.blank?
|
||||||
@replied_to_status = nil
|
@replied_to_status = nil
|
||||||
else
|
else
|
||||||
@replied_to_status = status_from_uri(in_reply_to_uri)
|
@replied_to_status = status_from_uri(in_reply_to_uri)
|
||||||
@replied_to_status ||= status_from_uri(@object['inReplyToAtomUri']) if @object['inReplyToAtomUri'].present?
|
|
||||||
@replied_to_status
|
@replied_to_status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,9 +32,7 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
|
||||||
Tombstone.find_or_create_by(uri: object_uri, account: @account)
|
Tombstone.find_or_create_by(uri: object_uri, account: @account)
|
||||||
end
|
end
|
||||||
|
|
||||||
@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?
|
|
||||||
|
|
||||||
return if @status.nil?
|
return if @status.nil?
|
||||||
|
|
||||||
forwarder.forward! if forwarder.forwardable?
|
forwarder.forward! if forwarder.forwardable?
|
||||||
|
|
|
@ -72,8 +72,7 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
|
||||||
def undo_announce
|
def undo_announce
|
||||||
return if object_uri.nil?
|
return if object_uri.nil?
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -179,8 +179,6 @@ class ActivityPub::TagManager
|
||||||
else
|
else
|
||||||
StatusFinder.new(uri).status
|
StatusFinder.new(uri).status
|
||||||
end
|
end
|
||||||
elsif OStatus::TagManager.instance.local_id?(uri)
|
|
||||||
klass.find_by(id: OStatus::TagManager.instance.unique_tag_to_local_id(uri, klass.to_s))
|
|
||||||
else
|
else
|
||||||
klass.find_by(uri: uri.split('#').first)
|
klass.find_by(uri: uri.split('#').first)
|
||||||
end
|
end
|
||||||
|
|
|
@ -59,15 +59,4 @@ class OStatus::TagManager
|
||||||
def local_id?(id)
|
def local_id?(id)
|
||||||
id.start_with?("tag:#{Rails.configuration.x.local_domain}") || ActivityPub::TagManager.instance.local_uri?(id)
|
id.start_with?("tag:#{Rails.configuration.x.local_domain}") || ActivityPub::TagManager.instance.local_uri?(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def uri_for(target)
|
|
||||||
return target.uri if target.respond_to?(:local?) && !target.local?
|
|
||||||
|
|
||||||
case target.object_type
|
|
||||||
when :person
|
|
||||||
account_url(target)
|
|
||||||
when :note, :comment, :activity
|
|
||||||
target.uri || unique_tag(target.created_at, target.id, 'Status')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
class ActivityPub::DeleteSerializer < ActivityPub::Serializer
|
class ActivityPub::DeleteSerializer < ActivityPub::Serializer
|
||||||
class TombstoneSerializer < ActivityPub::Serializer
|
class TombstoneSerializer < ActivityPub::Serializer
|
||||||
context_extensions :atom_uri
|
attributes :id, :type
|
||||||
|
|
||||||
attributes :id, :type, :atom_uri
|
|
||||||
|
|
||||||
def id
|
def id
|
||||||
ActivityPub::TagManager.instance.uri_for(object)
|
ActivityPub::TagManager.instance.uri_for(object)
|
||||||
|
@ -13,10 +11,6 @@ class ActivityPub::DeleteSerializer < ActivityPub::Serializer
|
||||||
def type
|
def type
|
||||||
'Tombstone'
|
'Tombstone'
|
||||||
end
|
end
|
||||||
|
|
||||||
def atom_uri
|
|
||||||
OStatus::TagManager.instance.uri_for(object)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
attributes :id, :type, :actor, :to
|
attributes :id, :type, :actor, :to
|
||||||
|
|
|
@ -3,12 +3,11 @@
|
||||||
class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
||||||
include FormattingHelper
|
include FormattingHelper
|
||||||
|
|
||||||
context_extensions :atom_uri, :conversation, :sensitive, :voters_count
|
context_extensions :conversation, :sensitive, :voters_count
|
||||||
|
|
||||||
attributes :id, :type, :summary,
|
attributes :id, :type, :summary,
|
||||||
:in_reply_to, :published, :url,
|
:in_reply_to, :published, :url,
|
||||||
:attributed_to, :to, :cc, :sensitive,
|
:attributed_to, :to, :cc, :sensitive,
|
||||||
:atom_uri, :in_reply_to_atom_uri,
|
|
||||||
:conversation
|
:conversation
|
||||||
|
|
||||||
attribute :content
|
attribute :content
|
||||||
|
@ -116,18 +115,6 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
||||||
object.active_mentions.to_a.sort_by(&:id) + object.tags + object.emojis
|
object.active_mentions.to_a.sort_by(&:id) + object.tags + object.emojis
|
||||||
end
|
end
|
||||||
|
|
||||||
def atom_uri
|
|
||||||
return unless object.local?
|
|
||||||
|
|
||||||
OStatus::TagManager.instance.uri_for(object)
|
|
||||||
end
|
|
||||||
|
|
||||||
def in_reply_to_atom_uri
|
|
||||||
return unless object.reply? && !object.thread.nil?
|
|
||||||
|
|
||||||
OStatus::TagManager.instance.uri_for(object.thread)
|
|
||||||
end
|
|
||||||
|
|
||||||
def conversation
|
def conversation
|
||||||
return if object.conversation.nil?
|
return if object.conversation.nil?
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,10 @@ 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
|
||||||
|
|
||||||
context 'when not atomUri' do
|
context 'when embedded object' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:status, reblog: status, account: sender, uri: 'bar')
|
Fabricate(:status, reblog: status, account: sender, uri: 'bar')
|
||||||
end
|
end
|
||||||
|
@ -42,17 +41,6 @@ RSpec.describe ActivityPub::Activity::Undo do
|
||||||
end
|
end
|
||||||
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
|
|
||||||
|
|
||||||
context 'with only object uri' do
|
context 'with only object uri' do
|
||||||
let(:object_json) { 'bar' }
|
let(:object_json) { 'bar' }
|
||||||
|
|
||||||
|
|
|
@ -170,11 +170,6 @@ RSpec.describe ActivityPub::TagManager do
|
||||||
expect(subject.uri_to_resource(subject.uri_for(status), Status)).to eq status
|
expect(subject.uri_to_resource(subject.uri_for(status), Status)).to eq status
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the local status for OStatus tag: URI' do
|
|
||||||
status = Fabricate(:status)
|
|
||||||
expect(subject.uri_to_resource(OStatus::TagManager.instance.uri_for(status), Status)).to eq status
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns the remote status by matching URI without fragment part' do
|
it 'returns the remote status by matching URI without fragment part' do
|
||||||
status = Fabricate(:status, uri: 'https://example.com/123')
|
status = Fabricate(:status, uri: 'https://example.com/123')
|
||||||
expect(subject.uri_to_resource('https://example.com/123#456', Status)).to eq status
|
expect(subject.uri_to_resource('https://example.com/123#456', Status)).to eq status
|
||||||
|
|
|
@ -36,35 +36,4 @@ describe OStatus::TagManager do
|
||||||
expect(described_class.instance.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false
|
expect(described_class.instance.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#uri_for' do
|
|
||||||
subject { described_class.instance.uri_for(target) }
|
|
||||||
|
|
||||||
context 'with comment object' do
|
|
||||||
let(:target) { Fabricate(:status, created_at: '2000-01-01T00:00:00Z', reply: true) }
|
|
||||||
|
|
||||||
it 'returns the unique tag for status' do
|
|
||||||
expect(target.object_type).to eq :comment
|
|
||||||
expect(subject).to eq target.uri
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with note object' do
|
|
||||||
let(:target) { Fabricate(:status, created_at: '2000-01-01T00:00:00Z', reply: false, thread: nil) }
|
|
||||||
|
|
||||||
it 'returns the unique tag for status' do
|
|
||||||
expect(target.object_type).to eq :note
|
|
||||||
expect(subject).to eq target.uri
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when person object' do
|
|
||||||
let(:target) { Fabricate(:account, username: 'alice') }
|
|
||||||
|
|
||||||
it 'returns the URL for account' do
|
|
||||||
expect(target.object_type).to eq :person
|
|
||||||
expect(subject).to eq 'https://cb6e6126.ngrok.io/users/alice'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -77,7 +77,6 @@ RSpec.describe RemoveStatusService, :inline_jobs do
|
||||||
'object' => {
|
'object' => {
|
||||||
'type' => 'Tombstone',
|
'type' => 'Tombstone',
|
||||||
'id' => ActivityPub::TagManager.instance.uri_for(status),
|
'id' => ActivityPub::TagManager.instance.uri_for(status),
|
||||||
'atomUri' => OStatus::TagManager.instance.uri_for(status),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user