diff --git a/Changelog.md b/Changelog.md index 2c71a9e69..e206bb038 100644 --- a/Changelog.md +++ b/Changelog.md @@ -23,6 +23,7 @@ Although the chat was never enabled per default and was marked as experimental, * Do not show getting started after account import [#8036](https://github.com/diaspora/diaspora/pull/8036) * Remove the JSXC/Prosody integration [#8069](https://github.com/diaspora/diaspora/pull/8069) * Replace factory\_girl with factory\_bot [#8218](https://github.com/diaspora/diaspora/pull/8218) +* Drop relay support [#8243](https://github.com/diaspora/diaspora/pull/8243) ## Bug fixes * Fix multiple photos upload progress bar [#7655](https://github.com/diaspora/diaspora/pull/7655) diff --git a/app/controllers/social_relay_controller.rb b/app/controllers/social_relay_controller.rb deleted file mode 100644 index 29cea8b40..000000000 --- a/app/controllers/social_relay_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class SocialRelayController < ApplicationController - respond_to :json - - def well_known - render json: SocialRelayPresenter.new - end -end diff --git a/app/presenters/social_relay_presenter.rb b/app/presenters/social_relay_presenter.rb deleted file mode 100644 index 5b6bf4746..000000000 --- a/app/presenters/social_relay_presenter.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class SocialRelayPresenter - def as_json(*) - { - "subscribe" => AppConfig.relay.inbound.subscribe?, - "scope" => AppConfig.relay.inbound.scope, - "tags" => tags - } - end - - def tags - return [] unless AppConfig.relay.inbound.scope == "tags" - tags = AppConfig.relay.inbound.pod_tags.present? ? AppConfig.relay.inbound.pod_tags.split(",").map(&:strip) : [] - add_user_tags(tags) - tags.uniq - end - - def add_user_tags(tags) - if AppConfig.relay.inbound.include_user_tags? - user_ids = User.halfyear_actives.pluck(:id) - tag_ids = TagFollowing.where(user: user_ids).select(:tag_id).distinct.pluck(:tag_id) - tags.concat ActsAsTaggableOn::Tag.where(id: tag_ids).pluck(:name) - end - end -end diff --git a/config/defaults.yml b/config/defaults.yml index 639ef6a52..fed76531f 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -174,15 +174,6 @@ defaults: admins: account: podmin_email: - relay: - outbound: - send: false - url: 'https://relay.iliketoast.net/receive/public' - inbound: - subscribe: false - scope: tags - include_user_tags: false - pod_tags: development: environment: diff --git a/config/diaspora.toml.example b/config/diaspora.toml.example index b41b4c1eb..c6c4fbea2 100644 --- a/config/diaspora.toml.example +++ b/config/diaspora.toml.example @@ -594,35 +594,6 @@ ## E-mail address via which the administrator can be contacted. #podmin_email = "podmin@example.org" -## Settings related to relays -## Relays are applications that exist to push public posts around to -## pods which want to subscribe to them but would not otherwise -## receive them due to not having direct contact with the remote pods. -## -## See more regarding relays: https://wiki.diasporafoundation.org/Relay_servers_for_public_posts -[configuration.relay] -## Enable this setting to send out public posts from this pod to a relay -#outbound.send = true - -## Change default remote relay url used for sending out here -#outbound.url = "https://relay.iliketoast.net/receive/public" - -## Enable this to receive public posts from relays -#inbound.subscribe = true - -## Scope is either "all" or "tags" (default="tags"). -## - "all", means this pod wants to receive all public posts from a relay -## - "tags", means this pod wants only posts tagged with certain tags -#inbound.scope = "tags" - -## If scope is "tags", should we include tags that users on this pod follow? -## These are added in addition to "pod_tags", if set. -#inbound.include_user_tags = false - -## If scope is "tags", a comma separated list of tags here can be set. -## For example "linux,diaspora", to receive posts related to these tags -#inbound.pod_tags = "linux,diaspora" - ## Advanced - ignore unless you know better ## You can override settings defined above if you need diff --git a/config/routes.rb b/config/routes.rb index e776cbb04..65ce0e8f1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,9 +221,6 @@ Rails.application.routes.draw do get 'terms' => 'terms#index' end - # Relay - get ".well-known/x-social-relay" => "social_relay#well_known" - # Startpage root :to => 'home#show' get "podmin", to: "home#podmin" diff --git a/lib/diaspora/federation/dispatcher/public.rb b/lib/diaspora/federation/dispatcher/public.rb index 51b7b5454..a82dfe09a 100644 --- a/lib/diaspora/federation/dispatcher/public.rb +++ b/lib/diaspora/federation/dispatcher/public.rb @@ -12,7 +12,7 @@ module Diaspora end def deliver_to_remote(people) - targets = target_urls(people) + additional_target_urls + targets = target_urls(people) return if targets.empty? @@ -25,11 +25,6 @@ module Diaspora active.map {|pod| pod.url_to("/receive/public") } end - def additional_target_urls - return [] unless AppConfig.relay.outbound.send? && object.instance_of?(StatusMessage) - [AppConfig.relay.outbound.url] - end - def deliver_to_hub logger.debug "deliver to pubsubhubbub sender: #{sender.diaspora_handle}" Workers::PublishToHub.perform_async(sender.atom_url) diff --git a/spec/controllers/social_relay_controller_spec.rb b/spec/controllers/social_relay_controller_spec.rb deleted file mode 100644 index 5754dc305..000000000 --- a/spec/controllers/social_relay_controller_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -describe SocialRelayController, type: :controller do - describe "#well_known" do - it "responds to format json" do - get :well_known, format: "json" - expect(response.code).to eq("200") - end - - it "contains json" do - get :well_known, format: "json" - json = JSON.parse(response.body) - expect(json["scope"]).to be_present - end - end -end diff --git a/spec/lib/diaspora/federation/dispatcher/public_spec.rb b/spec/lib/diaspora/federation/dispatcher/public_spec.rb index a14ae8d7b..59677cf43 100644 --- a/spec/lib/diaspora/federation/dispatcher/public_spec.rb +++ b/spec/lib/diaspora/federation/dispatcher/public_spec.rb @@ -17,38 +17,6 @@ describe Diaspora::Federation::Dispatcher::Public do end end - context "relay functionality" do - before do - AppConfig.relay.outbound.url = "https://relay.iliketoast.net/receive/public" - end - - it "delivers public post to relay when relay is enabled" do - AppConfig.relay.outbound.send = true - - expect(Workers::SendPublic).to receive(:perform_async) do |_user_id, _entity_string, urls, _xml| - expect(urls).to include("https://relay.iliketoast.net/receive/public") - end - - Diaspora::Federation::Dispatcher.build(alice, post).dispatch - end - - it "does not deliver post to relay when relay is disabled" do - AppConfig.relay.outbound.send = false - - expect(Workers::SendPublic).not_to receive(:perform_async) - - Diaspora::Federation::Dispatcher.build(alice, post).dispatch - end - - it "does not deliver comments to relay" do - AppConfig.relay.outbound.send = true - - expect(Workers::SendPublic).not_to receive(:perform_async) - - Diaspora::Federation::Dispatcher.build(alice, comment).dispatch - end - end - context "deliver to remote user" do let(:encryption_key) { double } let(:magic_env) { double } diff --git a/spec/presenters/social_relay_presenter_spec.rb b/spec/presenters/social_relay_presenter_spec.rb deleted file mode 100644 index bcec75695..000000000 --- a/spec/presenters/social_relay_presenter_spec.rb +++ /dev/null @@ -1,122 +0,0 @@ -# frozen_string_literal: true - -describe SocialRelayPresenter do - before do - @presenter = SocialRelayPresenter.new - end - - describe "#as_json" do - it "works" do - expect(@presenter.as_json).to be_present - expect(@presenter.as_json).to be_a Hash - end - end - - describe "#social relay well-known contents" do - describe "defaults" do - it "provides valid detault data" do - expect(@presenter.as_json).to eq( - "subscribe" => false, - "scope" => "tags", - "tags" => [] - ) - end - end - - describe "pod tags" do - before do - AppConfig.relay.inbound.pod_tags = "foo, bar" - AppConfig.relay.inbound.include_user_tags = false - end - - it "provides pod tags" do - expect(@presenter.as_json).to match( - "subscribe" => false, - "scope" => "tags", - "tags" => a_collection_containing_exactly("foo", "bar") - ) - end - end - - describe "user tags" do - before do - AppConfig.relay.inbound.pod_tags = "" - AppConfig.relay.inbound.include_user_tags = true - ceetag = FactoryBot.create(:tag, name: "cee") - lootag = FactoryBot.create(:tag, name: "loo") - FactoryBot.create(:tag_following, user: alice, tag: ceetag) - FactoryBot.create(:tag_following, user: alice, tag: lootag) - alice.last_seen = Time.zone.now - 2.months - alice.save - end - - it "provides user tags" do - expect(@presenter.as_json).to match( - "subscribe" => false, - "scope" => "tags", - "tags" => a_collection_containing_exactly("cee", "loo") - ) - end - end - - describe "pod tags combined with user tags" do - before do - AppConfig.relay.inbound.pod_tags = "foo, bar" - AppConfig.relay.inbound.include_user_tags = true - ceetag = FactoryBot.create(:tag, name: "cee") - lootag = FactoryBot.create(:tag, name: "loo") - FactoryBot.create(:tag_following, user: alice, tag: ceetag) - FactoryBot.create(:tag_following, user: alice, tag: lootag) - alice.last_seen = Time.zone.now - 2.months - alice.save - end - - it "provides combined pod and user tags" do - expect(@presenter.as_json).to match( - "subscribe" => false, - "scope" => "tags", - "tags" => a_collection_containing_exactly("foo", "bar", "cee", "loo") - ) - end - end - - describe "user tags for inactive user" do - before do - AppConfig.relay.inbound.pod_tags = "" - AppConfig.relay.inbound.include_user_tags = true - ceetag = FactoryBot.create(:tag, name: "cee") - lootag = FactoryBot.create(:tag, name: "loo") - FactoryBot.create(:tag_following, user: alice, tag: ceetag) - FactoryBot.create(:tag_following, user: alice, tag: lootag) - alice.last_seen = Time.zone.now - 8.months - alice.save - end - - it "ignores user tags" do - expect(@presenter.as_json).to eq( - "subscribe" => false, - "scope" => "tags", - "tags" => [] - ) - end - end - - describe "when scope is all" do - before do - AppConfig.relay.inbound.scope = "all" - AppConfig.relay.inbound.pod_tags = "foo,bar" - AppConfig.relay.inbound.include_user_tags = true - ceetag = FactoryBot.create(:tag, name: "cee") - FactoryBot.create(:tag_following, user: alice, tag: ceetag) - end - - it "provides empty tags list" do - expect(@presenter.as_json).to eq( - "subscribe" => false, - "scope" => "all", - "tags" => [] - ) - end - end - end -end