From 9110db41c53a2f3f22affc23b364362133997d3e Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 4 Mar 2018 09:19:11 +0100 Subject: Federate pinned statuses over ActivityPub (#6610) * Federate pinned statuses over ActivityPub * Display pinned toots in web UI Fix #6117 * Fix migration * Fix tests * Update outbox_serializer.rb * Update remove_serializer.rb * Update add_serializer.rb * Update fetch_featured_collection_service.rb --- spec/lib/activitypub/activity/remove_spec.rb | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/lib/activitypub/activity/remove_spec.rb (limited to 'spec/lib/activitypub/activity/remove_spec.rb') diff --git a/spec/lib/activitypub/activity/remove_spec.rb b/spec/lib/activitypub/activity/remove_spec.rb new file mode 100644 index 000000000..c3f015053 --- /dev/null +++ b/spec/lib/activitypub/activity/remove_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' + +RSpec.describe ActivityPub::Activity::Remove do + let(:sender) { Fabricate(:account, featured_collection_url: 'https://example.com/featured') } + let(:status) { Fabricate(:status, account: sender) } + + let(:json) do + { + '@context': 'https://www.w3.org/ns/activitystreams', + id: 'foo', + type: 'Add', + actor: ActivityPub::TagManager.instance.uri_for(sender), + object: ActivityPub::TagManager.instance.uri_for(status), + origin: sender.featured_collection_url, + }.with_indifferent_access + end + + describe '#perform' do + subject { described_class.new(json, sender) } + + before do + StatusPin.create!(account: sender, status: status) + subject.perform + end + + it 'removes a pin' do + expect(sender.pinned?(status)).to be false + end + end +end -- cgit From e6520c027014aae9444dc58f8b3e7b618214a574 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 7 Mar 2018 03:54:46 +0100 Subject: Fix #6657 - Use target instead of origin in Remove activity (#6664) --- app/lib/activitypub/activity/remove.rb | 2 +- app/serializers/activitypub/remove_serializer.rb | 4 ++-- spec/lib/activitypub/activity/remove_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/lib/activitypub/activity/remove_spec.rb') diff --git a/app/lib/activitypub/activity/remove.rb b/app/lib/activitypub/activity/remove.rb index 97cee5116..62a1e3196 100644 --- a/app/lib/activitypub/activity/remove.rb +++ b/app/lib/activitypub/activity/remove.rb @@ -2,7 +2,7 @@ class ActivityPub::Activity::Remove < ActivityPub::Activity def perform - return unless @json['origin'].present? && value_or_id(@json['origin']) == @account.featured_collection_url + return unless @json['target'].present? && value_or_id(@json['target']) == @account.featured_collection_url status = status_from_uri(object_uri) diff --git a/app/serializers/activitypub/remove_serializer.rb b/app/serializers/activitypub/remove_serializer.rb index 6da7e35d3..c35ee916e 100644 --- a/app/serializers/activitypub/remove_serializer.rb +++ b/app/serializers/activitypub/remove_serializer.rb @@ -3,7 +3,7 @@ class ActivityPub::RemoveSerializer < ActiveModel::Serializer include RoutingHelper - attributes :type, :actor, :origin + attributes :type, :actor, :target attribute :proper_object, key: :object def type @@ -18,7 +18,7 @@ class ActivityPub::RemoveSerializer < ActiveModel::Serializer ActivityPub::TagManager.instance.uri_for(object) end - def origin + def target account_collection_url(object, :featured) end end diff --git a/spec/lib/activitypub/activity/remove_spec.rb b/spec/lib/activitypub/activity/remove_spec.rb index c3f015053..4209dfde2 100644 --- a/spec/lib/activitypub/activity/remove_spec.rb +++ b/spec/lib/activitypub/activity/remove_spec.rb @@ -11,7 +11,7 @@ RSpec.describe ActivityPub::Activity::Remove do type: 'Add', actor: ActivityPub::TagManager.instance.uri_for(sender), object: ActivityPub::TagManager.instance.uri_for(status), - origin: sender.featured_collection_url, + target: sender.featured_collection_url, }.with_indifferent_access end -- cgit