diff options
author | Claire <claire.github-309c@sitedethib.com> | 2024-07-15 10:31:19 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2024-07-15 11:56:09 +0200 |
commit | d3e0eb8c0086c59309a39553cbd7bc8f8c647a9e (patch) | |
tree | 27b5a86e041c2d380e2ccc76298c8fadaecce3e2 | |
parent | 00cb4a0313190bfa118966692a649db9c8328094 (diff) |
Drop support for `atomUri` and `inReplyToAtomUri`cleanup/drop-atomuri
-rw-r--r-- | app/helpers/context_helper.rb | 3 | ||||
-rw-r--r-- | app/lib/activitypub/activity/create.rb | 6 | ||||
-rw-r--r-- | app/lib/activitypub/activity/delete.rb | 4 | ||||
-rw-r--r-- | app/lib/activitypub/activity/undo.rb | 3 | ||||
-rw-r--r-- | app/lib/activitypub/tag_manager.rb | 2 | ||||
-rw-r--r-- | app/lib/ostatus/tag_manager.rb | 11 | ||||
-rw-r--r-- | app/serializers/activitypub/delete_serializer.rb | 8 | ||||
-rw-r--r-- | app/serializers/activitypub/note_serializer.rb | 15 | ||||
-rw-r--r-- | spec/lib/activitypub/activity/undo_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/activitypub/tag_manager_spec.rb | 5 | ||||
-rw-r--r-- | spec/lib/ostatus/tag_manager_spec.rb | 31 | ||||
-rw-r--r-- | spec/services/remove_status_service_spec.rb | 1 |
12 files changed, 8 insertions, 95 deletions
diff --git a/app/helpers/context_helper.rb b/app/helpers/context_helper.rb index cbefe0fe538..87fb30dcf3b 100644 --- a/app/helpers/context_helper.rb +++ b/app/helpers/context_helper.rb @@ -15,8 +15,7 @@ module ContextHelper 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' } }, 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#', 'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri', 'conversation' => 'ostatus:conversation' }, + conversation: { 'ostatus' => 'http://ostatus.org#', 'conversation' => 'ostatus:conversation' }, focal_point: { 'toot' => 'http://joinmastodon.org/ns#', 'focalPoint' => { '@container' => '@list', '@id' => 'toot:focalPoint' } }, blurhash: { 'toot' => 'http://joinmastodon.org/ns#', 'blurhash' => 'toot:blurhash' }, discoverable: { 'toot' => 'http://joinmastodon.org/ns#', 'discoverable' => 'toot:discoverable' }, diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 5d700b49613..0f7feef9e7b 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -102,8 +102,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity end def find_existing_status - status = status_from_uri(object_uri) - status ||= Status.find_by(uri: @object['atomUri']) if @object['atomUri'].present? + status = status_from_uri(object_uri) status if status&.account_id == @account.id end @@ -362,8 +361,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity if in_reply_to_uri.blank? @replied_to_status = nil else - @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 = status_from_uri(in_reply_to_uri) @replied_to_status end end diff --git a/app/lib/activitypub/activity/delete.rb b/app/lib/activitypub/activity/delete.rb index 61f6ca69977..96fe6f1d971 100644 --- a/app/lib/activitypub/activity/delete.rb +++ b/app/lib/activitypub/activity/delete.rb @@ -32,9 +32,7 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity Tombstone.find_or_create_by(uri: object_uri, account: @account) end - @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? - + @status = Status.find_by(uri: object_uri, account: @account) return if @status.nil? forwarder.forward! if forwarder.forwardable? diff --git a/app/lib/activitypub/activity/undo.rb b/app/lib/activitypub/activity/undo.rb index 9eff1b71c9d..b79160eee01 100644 --- a/app/lib/activitypub/activity/undo.rb +++ b/app/lib/activitypub/activity/undo.rb @@ -72,8 +72,7 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity def undo_announce return if object_uri.nil? - 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? + status = Status.find_by(uri: object_uri, account: @account) if status.nil? delete_later!(object_uri) diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index 86432863175..8bc31e2a909 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -179,8 +179,6 @@ class ActivityPub::TagManager else StatusFinder.new(uri).status 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 klass.find_by(uri: uri.split('#').first) end diff --git a/app/lib/ostatus/tag_manager.rb b/app/lib/ostatus/tag_manager.rb index 21b3d3aa584..96c11f571ec 100644 --- a/app/lib/ostatus/tag_manager.rb +++ b/app/lib/ostatus/tag_manager.rb @@ -59,15 +59,4 @@ class OStatus::TagManager def local_id?(id) id.start_with?("tag:#{Rails.configuration.x.local_domain}") || ActivityPub::TagManager.instance.local_uri?(id) 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 diff --git a/app/serializers/activitypub/delete_serializer.rb b/app/serializers/activitypub/delete_serializer.rb index a7d5bd46985..c8f918c92f2 100644 --- a/app/serializers/activitypub/delete_serializer.rb +++ b/app/serializers/activitypub/delete_serializer.rb @@ -2,9 +2,7 @@ class ActivityPub::DeleteSerializer < ActivityPub::Serializer class TombstoneSerializer < ActivityPub::Serializer - context_extensions :atom_uri - - attributes :id, :type, :atom_uri + attributes :id, :type def id ActivityPub::TagManager.instance.uri_for(object) @@ -13,10 +11,6 @@ class ActivityPub::DeleteSerializer < ActivityPub::Serializer def type 'Tombstone' end - - def atom_uri - OStatus::TagManager.instance.uri_for(object) - end end attributes :id, :type, :actor, :to diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index 27e058199d6..63cab572648 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -3,12 +3,11 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer include FormattingHelper - context_extensions :atom_uri, :conversation, :sensitive, :voters_count + context_extensions :conversation, :sensitive, :voters_count attributes :id, :type, :summary, :in_reply_to, :published, :url, :attributed_to, :to, :cc, :sensitive, - :atom_uri, :in_reply_to_atom_uri, :conversation attribute :content @@ -116,18 +115,6 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer object.active_mentions.to_a.sort_by(&:id) + object.tags + object.emojis 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 return if object.conversation.nil? diff --git a/spec/lib/activitypub/activity/undo_spec.rb b/spec/lib/activitypub/activity/undo_spec.rb index 58e71fc4e8d..a312ac05b5a 100644 --- a/spec/lib/activitypub/activity/undo_spec.rb +++ b/spec/lib/activitypub/activity/undo_spec.rb @@ -27,11 +27,10 @@ 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 'when not atomUri' do + context 'when embedded object' do before do Fabricate(:status, reblog: status, account: sender, uri: 'bar') end @@ -42,17 +41,6 @@ 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 - context 'with only object uri' do let(:object_json) { 'bar' } diff --git a/spec/lib/activitypub/tag_manager_spec.rb b/spec/lib/activitypub/tag_manager_spec.rb index 05d2609b0da..2cf935b786a 100644 --- a/spec/lib/activitypub/tag_manager_spec.rb +++ b/spec/lib/activitypub/tag_manager_spec.rb @@ -170,11 +170,6 @@ RSpec.describe ActivityPub::TagManager do expect(subject.uri_to_resource(subject.uri_for(status), Status)).to eq status 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 status = Fabricate(:status, uri: 'https://example.com/123') expect(subject.uri_to_resource('https://example.com/123#456', Status)).to eq status diff --git a/spec/lib/ostatus/tag_manager_spec.rb b/spec/lib/ostatus/tag_manager_spec.rb index 0e20f26c7c3..94bd4531468 100644 --- a/spec/lib/ostatus/tag_manager_spec.rb +++ b/spec/lib/ostatus/tag_manager_spec.rb @@ -36,35 +36,4 @@ describe OStatus::TagManager do expect(described_class.instance.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false 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 diff --git a/spec/services/remove_status_service_spec.rb b/spec/services/remove_status_service_spec.rb index 08f519b5360..68692ac4de2 100644 --- a/spec/services/remove_status_service_spec.rb +++ b/spec/services/remove_status_service_spec.rb @@ -77,7 +77,6 @@ RSpec.describe RemoveStatusService, :inline_jobs do 'object' => { 'type' => 'Tombstone', 'id' => ActivityPub::TagManager.instance.uri_for(status), - 'atomUri' => OStatus::TagManager.instance.uri_for(status), } ) end |