Merge pull request #8243 from tclaus/8192_drop_relay_example
drop relay example and implementation closes #8192
This commit is contained in:
commit
1dd2382d03
10 changed files with 2 additions and 252 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SocialRelayController < ApplicationController
|
||||
respond_to :json
|
||||
|
||||
def well_known
|
||||
render json: SocialRelayPresenter.new
|
||||
end
|
||||
end
|
||||
|
|
@ -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
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in a new issue