From 47ef4a6c7a74072daff8b23c4af3e300bb75ba1a Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 25 Jun 2019 14:45:14 +0200 Subject: Apply filters to poll options (#11174) * Apply filters to poll options in WebUI Fixes #11128 * Apply filters to poll options server-side * Add poll options to searchable text --- spec/lib/feed_manager_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec') diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb index 5f8eb86a8..9bdb675e1 100644 --- a/spec/lib/feed_manager_spec.rb +++ b/spec/lib/feed_manager_spec.rb @@ -149,6 +149,14 @@ RSpec.describe FeedManager do status = Fabricate(:status, text: 'shiitake', account: jeff) expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true end + + it 'returns true if phrase is contained in a poll option' do + alice.custom_filters.create!(phrase: 'farts', context: %w(home public), irreversible: true) + alice.custom_filters.create!(phrase: 'pop tarts', context: %w(home), irreversible: true) + alice.follow!(jeff) + status = Fabricate(:status, text: 'what do you prefer', poll: Fabricate(:poll, options: %w(farts POP TARts)), account: jeff) + expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true + end end end -- cgit From 915c619394165a114a4ab316165aecac3386cf2f Mon Sep 17 00:00:00 2001 From: ThibG Date: Wed, 26 Jun 2019 19:32:36 +0200 Subject: Add support for Audio activities (#11189) Fixes #11127 --- app/lib/activitypub/activity.rb | 2 +- app/services/resolve_url_service.rb | 4 +-- .../fetch_remote_status_service_spec.rb | 33 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 66b5763a9..a4a9baaee 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -5,7 +5,7 @@ class ActivityPub::Activity include Redisable SUPPORTED_TYPES = %w(Note Question).freeze - CONVERTED_TYPES = %w(Image Video Article Page).freeze + CONVERTED_TYPES = %w(Image Audio Video Article Page).freeze def initialize(json, account, **options) @json = json diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb index b98759bf6..bbdc0a595 100644 --- a/app/services/resolve_url_service.rb +++ b/app/services/resolve_url_service.rb @@ -18,9 +18,9 @@ class ResolveURLService < BaseService private def process_url - if equals_or_includes_any?(type, %w(Application Group Organization Person Service)) + if equals_or_includes_any?(type, ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES) FetchRemoteAccountService.new.call(atom_url, body, protocol) - elsif equals_or_includes_any?(type, %w(Note Article Image Video Page Question)) + elsif equals_or_includes_any?(type, ActivityPub::Activity::Create::SUPPORTED_TYPES + ActivityPub::Activity::Create::CONVERTED_TYPES) FetchRemoteStatusService.new.call(atom_url, body, protocol) end end diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index 9ae409996..78dd59e3b 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -71,6 +71,39 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do end end + context 'with Audio object' do + let(:object) do + { + '@context': 'https://www.w3.org/ns/activitystreams', + id: "https://#{valid_domain}/@foo/1234", + type: 'Audio', + name: 'Nyan Cat 10 hours remix', + attributedTo: ActivityPub::TagManager.instance.uri_for(sender), + url: [ + { + type: 'Link', + mimeType: 'application/x-bittorrent', + href: "https://#{valid_domain}/12345.torrent", + }, + + { + type: 'Link', + mimeType: 'text/html', + href: "https://#{valid_domain}/watch?v=12345", + }, + ], + } + end + + it 'creates status' do + status = sender.statuses.first + + expect(status).to_not be_nil + expect(status.url).to eq "https://#{valid_domain}/watch?v=12345" + expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remix https://#{valid_domain}/watch?v=12345" + end + end + context 'with wrong id' do let(:note) do { -- cgit