diff --git a/Gemfile b/Gemfile index 72fca1cd7..51721acfb 100644 --- a/Gemfile +++ b/Gemfile @@ -15,8 +15,8 @@ gem "unicorn-worker-killer", "0.4.5" # Federation -gem "diaspora_federation-json_schema", "0.2.8" -gem "diaspora_federation-rails", "0.2.8" +gem "diaspora_federation-json_schema", "1.0.0" +gem "diaspora_federation-rails", "1.0.0" # API and JSON @@ -142,11 +142,11 @@ gem "acts-as-taggable-on", "9.0.1" # URIs and HTTP -gem "addressable", "2.8.0", require: "addressable/uri" -gem "faraday", "0.17.5" -gem "faraday-cookie_jar", "0.0.7" -gem "faraday_middleware", "0.14.0" -gem "typhoeus", "1.4.0" +gem "addressable", "2.8.0", require: "addressable/uri" +gem "faraday", "1.10.0" +gem "faraday-cookie_jar", "0.0.7" +gem "faraday-follow_redirects", "0.3.0" +gem "typhoeus", "1.4.0" # Views @@ -245,7 +245,7 @@ group :test do gem "timecop", "0.9.5" gem "webmock", "3.14.0", require: false - gem "diaspora_federation-test", "0.2.8" + gem "diaspora_federation-test", "1.0.0" end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 991c1cc58..f3eda0a79 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -209,19 +209,19 @@ GEM devise_lastseenable (0.0.6) devise rails (>= 3.0.4) - diaspora_federation (0.2.8) - faraday (>= 0.9.0, < 1.0) - faraday_middleware (>= 0.10.0, < 1.0) + diaspora_federation (1.0.0) + faraday (>= 1.0, < 3) + faraday-follow_redirects (~> 0.3) nokogiri (~> 1.6, >= 1.6.8) typhoeus (~> 1.0) valid (~> 1.0) - diaspora_federation-json_schema (0.2.8) - diaspora_federation-rails (0.2.8) - actionpack (>= 4.2, < 7) - diaspora_federation (= 0.2.8) - diaspora_federation-test (0.2.8) - diaspora_federation (= 0.2.8) - fabrication (~> 2.16) + diaspora_federation-json_schema (1.0.0) + diaspora_federation-rails (1.0.0) + actionpack (>= 5.2, < 8) + diaspora_federation (= 1.0.0) + diaspora_federation-test (1.0.0) + diaspora_federation (= 1.0.0) + fabrication (~> 2.29) uuid (~> 2.3, >= 2.3.8) diff-lcs (1.5.0) docile (1.4.0) @@ -246,19 +246,40 @@ GEM kostya-sigar (~> 2.0.0) state_machines thor - fabrication (2.22.0) + fabrication (2.29.0) factory_bot (6.1.0) activesupport (>= 5.0.0) factory_bot_rails (6.1.0) factory_bot (~> 6.1.0) railties (>= 5.0.0) - faraday (0.17.5) - multipart-post (>= 1.2, < 3) + faraday (1.10.0) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) + ruby2_keywords (>= 0.0.4) faraday-cookie_jar (0.0.7) faraday (>= 0.8.0) http-cookie (~> 1.0.0) - faraday_middleware (0.14.0) - faraday (>= 0.7.4, < 1.0) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) + faraday-httpclient (1.0.1) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.3) ffi (1.15.5) ffi-compiler (1.0.1) ffi (>= 1.0.0) @@ -618,6 +639,7 @@ GEM ruby-progressbar (1.11.0) ruby-vips (2.1.4) ffi (~> 1.12) + ruby2_keywords (0.0.5) rubyzip (2.3.2) rugged (1.0.1) sass (3.4.25) @@ -707,7 +729,7 @@ GEM unf (~> 0.1.0) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (2.0.4) + tzinfo (2.0.5) concurrent-ruby (~> 1.0) unf (0.1.4) unf_ext @@ -778,14 +800,14 @@ DEPENDENCIES devise (= 4.8.1) devise-two-factor (= 4.0.2) devise_lastseenable (= 0.0.6) - diaspora_federation-json_schema (= 0.2.8) - diaspora_federation-rails (= 0.2.8) - diaspora_federation-test (= 0.2.8) + diaspora_federation-json_schema (= 1.0.0) + diaspora_federation-rails (= 1.0.0) + diaspora_federation-test (= 1.0.0) eye (= 0.10.0) factory_bot_rails (= 6.1.0) - faraday (= 0.17.5) + faraday (= 1.10.0) faraday-cookie_jar (= 0.0.7) - faraday_middleware (= 0.14.0) + faraday-follow_redirects (= 0.3.0) fixture_builder (= 0.5.2) fog-aws (= 3.14.0) fuubar (= 2.5.1) diff --git a/app/workers/receive_base.rb b/app/workers/receive_base.rb index 48c424291..3c84b302a 100644 --- a/app/workers/receive_base.rb +++ b/app/workers/receive_base.rb @@ -26,12 +26,7 @@ module Workers DiasporaFederation::Salmon::InvalidEncoding, Diaspora::Federation::AuthorIgnored, Diaspora::Federation::InvalidAuthor, - Diaspora::Federation::RecipientClosed, - # TODO: deprecated - DiasporaFederation::Salmon::MissingMagicEnvelope, - DiasporaFederation::Salmon::MissingAuthor, - DiasporaFederation::Salmon::MissingHeader, - DiasporaFederation::Salmon::InvalidHeader => e + Diaspora::Federation::RecipientClosed => e logger.warn "don't retry for error: #{e.class}" end end diff --git a/app/workers/receive_private.rb b/app/workers/receive_private.rb index 18534d6f9..580890ea4 100644 --- a/app/workers/receive_private.rb +++ b/app/workers/receive_private.rb @@ -6,11 +6,11 @@ module Workers class ReceivePrivate < ReceiveBase - def perform(user_id, data, legacy) + def perform(user_id, data) filter_errors_for_retry do user_private_key = User.where(id: user_id).pluck(:serialized_private_key).first rsa_key = OpenSSL::PKey::RSA.new(user_private_key) - DiasporaFederation::Federation::Receiver.receive_private(data, rsa_key, user_id, legacy) + DiasporaFederation::Federation::Receiver.receive_private(data, rsa_key, user_id) end end end diff --git a/app/workers/receive_public.rb b/app/workers/receive_public.rb index 23c1f72c2..d89850e28 100644 --- a/app/workers/receive_public.rb +++ b/app/workers/receive_public.rb @@ -6,9 +6,9 @@ module Workers class ReceivePublic < ReceiveBase - def perform(data, legacy=false) + def perform(data) filter_errors_for_retry do - DiasporaFederation::Federation::Receiver.receive_public(data, legacy) + DiasporaFederation::Federation::Receiver.receive_public(data) end end end diff --git a/config/initializers/diaspora_federation.rb b/config/initializers/diaspora_federation.rb index 1f56f5c1a..19a9fdfe4 100644 --- a/config/initializers/diaspora_federation.rb +++ b/config/initializers/diaspora_federation.rb @@ -44,7 +44,6 @@ DiasporaFederation.configure do |config| guid: person.guid, nickname: person.username, full_name: "#{person.profile.first_name} #{person.profile.last_name}".strip, - url: AppConfig.pod_uri, photo_large_url: person.image_url, photo_medium_url: person.image_url(size: :thumb_medium), photo_small_url: person.image_url(size: :thumb_small), @@ -90,15 +89,15 @@ DiasporaFederation.configure do |config| Diaspora::Federation::Entities.related_entity(entity) if entity end - on :queue_public_receive do |xml, legacy=false| - Workers::ReceivePublic.perform_async(xml, legacy) + on :queue_public_receive do |xml| + Workers::ReceivePublic.perform_async(xml) end - on :queue_private_receive do |guid, xml, legacy=false| + on :queue_private_receive do |guid, xml| person = Person.find_by_guid(guid) (person.present? && person.owner_id.present?).tap do |user_found| - Workers::ReceivePrivate.perform_async(person.owner.id, xml, legacy) if user_found + Workers::ReceivePrivate.perform_async(person.owner.id, xml) if user_found end end diff --git a/config/initializers/faraday.rb b/config/initializers/faraday.rb index a54963221..76f9d0a32 100644 --- a/config/initializers/faraday.rb +++ b/config/initializers/faraday.rb @@ -20,7 +20,7 @@ options = { } Faraday.default_connection = Faraday::Connection.new(options) do |b| - b.use FaradayMiddleware::FollowRedirects, limit: 8 + b.use Faraday::FollowRedirects::Middleware, limit: 8 b.use :cookie_jar b.adapter Faraday.default_adapter end diff --git a/lib/connection_tester.rb b/lib/connection_tester.rb index 5bc58d75b..ef5a4abf8 100644 --- a/lib/connection_tester.rb +++ b/lib/connection_tester.rb @@ -114,7 +114,7 @@ class ConnectionTester raise NetFailure, e.message rescue Faraday::SSLError => e raise SSLFailure, e.message - rescue ArgumentError, FaradayMiddleware::RedirectLimitReached, Faraday::ClientError => e + rescue ArgumentError, Faraday::FollowRedirects::RedirectLimitReached, Faraday::ClientError => e raise HTTPFailure, e.message rescue StandardError => e unexpected_error(e) @@ -146,7 +146,7 @@ class ConnectionTester def with_http_connection @http ||= Faraday.new(@url) do |c| c.use Faraday::Response::RaiseError - c.use FaradayMiddleware::FollowRedirects, limit: 3 + c.use Faraday::FollowRedirects::Middleware, limit: 3 c.adapter(Faraday.default_adapter) c.headers[:user_agent] = "diaspora-connection-tester" c.options.timeout = 12 diff --git a/lib/pubsubhubbub.rb b/lib/pubsubhubbub.rb index 66f899ba6..a6a566173 100644 --- a/lib/pubsubhubbub.rb +++ b/lib/pubsubhubbub.rb @@ -14,8 +14,8 @@ class Pubsubhubbub conn = Faraday.new do |c| c.use Faraday::Request::UrlEncoded # encode request params as "www-form-urlencoded" - c.use Faraday::Adapter::NetHttp # perform requests with Net::HTTP + c.adapter Faraday::Adapter::NetHttp # perform requests with Net::HTTP end conn.post @hub, {'hub.url' => feed, 'hub.mode' => 'publish'} end -end \ No newline at end of file +end diff --git a/spec/federation_callbacks_spec.rb b/spec/federation_callbacks_spec.rb index bd33d3bd6..6200af866 100644 --- a/spec/federation_callbacks_spec.rb +++ b/spec/federation_callbacks_spec.rb @@ -50,7 +50,6 @@ describe "diaspora federation callbacks" do expect(hcard.guid).to eq(person.guid) expect(hcard.nickname).to eq(person.username) expect(hcard.full_name).to eq("#{person.profile.first_name} #{person.profile.last_name}") - expect(hcard.url).to eq(AppConfig.pod_uri) expect(hcard.photo_large_url).to eq(person.image_url) expect(hcard.photo_medium_url).to eq(person.image_url(size: :thumb_medium)) expect(hcard.photo_small_url).to eq(person.image_url(size: :thumb_small)) @@ -310,9 +309,9 @@ describe "diaspora federation callbacks" do describe ":queue_public_receive" do it "enqueues a ReceivePublic job" do data = "" - expect(Workers::ReceivePublic).to receive(:perform_async).with(data, true) + expect(Workers::ReceivePublic).to receive(:perform_async).with(data) - DiasporaFederation.callbacks.trigger(:queue_public_receive, data, true) + DiasporaFederation.callbacks.trigger(:queue_public_receive, data) end end @@ -325,19 +324,19 @@ describe "diaspora federation callbacks" do end it "enqueues a ReceivePrivate job" do - expect(Workers::ReceivePrivate).to receive(:perform_async).with(alice.id, data, true) + expect(Workers::ReceivePrivate).to receive(:perform_async).with(alice.id, data) - DiasporaFederation.callbacks.trigger(:queue_private_receive, alice.person.guid, data, true) + DiasporaFederation.callbacks.trigger(:queue_private_receive, alice.person.guid, data) end it "returns false if the no user is found" do person = FactoryBot.create(:person) - result = DiasporaFederation.callbacks.trigger(:queue_private_receive, person.guid, data, true) + result = DiasporaFederation.callbacks.trigger(:queue_private_receive, person.guid, data) expect(result).to be_falsey end it "returns false if the no person is found" do - result = DiasporaFederation.callbacks.trigger(:queue_private_receive, "2398rq3948yftn", data, true) + result = DiasporaFederation.callbacks.trigger(:queue_private_receive, "2398rq3948yftn", data) expect(result).to be_falsey end end diff --git a/spec/integration/federation/federation_helper.rb b/spec/integration/federation/federation_helper.rb index 2e471f711..76395c509 100644 --- a/spec/integration/federation/federation_helper.rb +++ b/spec/integration/federation/federation_helper.rb @@ -55,10 +55,6 @@ def allow_callbacks(callbacks) end def create_relayable_entity(entity_name, parent, diaspora_id) - expect(DiasporaFederation.callbacks).to receive(:trigger).with( - :fetch_private_key, alice.diaspora_handle - ).at_least(1).times.and_return(nil) if parent == local_parent - Fabricate( entity_name, parent_guid: parent.guid, diff --git a/spec/workers/receive_private_spec.rb b/spec/workers/receive_private_spec.rb index 288db75e3..0f3de7a9e 100644 --- a/spec/workers/receive_private_spec.rb +++ b/spec/workers/receive_private_spec.rb @@ -7,9 +7,9 @@ describe Workers::ReceivePrivate do rsa_key = double expect(OpenSSL::PKey::RSA).to receive(:new).with(alice.serialized_private_key).and_return(rsa_key) - expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with(data, rsa_key, alice.id, true) + expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with(data, rsa_key, alice.id) - Workers::ReceivePrivate.new.perform(alice.id, data, true) + Workers::ReceivePrivate.new.perform(alice.id, data) end it "filters errors that would also fail on second try" do @@ -17,11 +17,11 @@ describe Workers::ReceivePrivate do expect(OpenSSL::PKey::RSA).to receive(:new).with(alice.serialized_private_key).and_return(rsa_key) expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with( - data, rsa_key, alice.id, false + data, rsa_key, alice.id ).and_raise(DiasporaFederation::Salmon::InvalidSignature) expect { - Workers::ReceivePrivate.new.perform(alice.id, data, false) + Workers::ReceivePrivate.new.perform(alice.id, data) }.not_to raise_error end @@ -30,11 +30,11 @@ describe Workers::ReceivePrivate do expect(OpenSSL::PKey::RSA).to receive(:new).with(alice.serialized_private_key).and_return(rsa_key) expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with( - data, rsa_key, alice.id, false + data, rsa_key, alice.id ).and_raise(DiasporaFederation::Federation::Fetcher::NotFetchable) expect { - Workers::ReceivePrivate.new.perform(alice.id, data, false) + Workers::ReceivePrivate.new.perform(alice.id, data) }.to raise_error DiasporaFederation::Federation::Fetcher::NotFetchable end end diff --git a/spec/workers/receive_public_spec.rb b/spec/workers/receive_public_spec.rb index 2b97dbd20..ed543fa9f 100644 --- a/spec/workers/receive_public_spec.rb +++ b/spec/workers/receive_public_spec.rb @@ -4,28 +4,26 @@ describe Workers::ReceivePublic do let(:data) { "" } it "calls receive_public of federation gem" do - expect(DiasporaFederation::Federation::Receiver).to receive(:receive_public).with(data, true) + expect(DiasporaFederation::Federation::Receiver).to receive(:receive_public).with(data) - Workers::ReceivePublic.new.perform(data, true) + Workers::ReceivePublic.new.perform(data) end it "filters errors that would also fail on second try" do - expect(DiasporaFederation::Federation::Receiver).to receive(:receive_public).with( - data, false - ).and_raise(DiasporaFederation::Salmon::InvalidSignature) + expect(DiasporaFederation::Federation::Receiver) + .to receive(:receive_public).with(data).and_raise(DiasporaFederation::Salmon::InvalidSignature) expect { - Workers::ReceivePublic.new.perform(data, false) + Workers::ReceivePublic.new.perform(data) }.not_to raise_error end it "does not filter errors that would succeed on second try" do - expect(DiasporaFederation::Federation::Receiver).to receive(:receive_public).with( - data, false - ).and_raise(DiasporaFederation::Federation::Fetcher::NotFetchable) + expect(DiasporaFederation::Federation::Receiver) + .to receive(:receive_public).with(data).and_raise(DiasporaFederation::Federation::Fetcher::NotFetchable) expect { - Workers::ReceivePublic.new.perform(data, false) + Workers::ReceivePublic.new.perform(data) }.to raise_error DiasporaFederation::Federation::Fetcher::NotFetchable end end