Remove NodeInfo integration

This commit is contained in:
Andreas Nedbal 2025-03-02 02:39:33 +01:00 committed by Andreas Nedbal
parent 5decee81b1
commit 432a5239d5
3 changed files with 0 additions and 123 deletions

View file

@ -1,54 +0,0 @@
# frozen_string_literal: true
class WellKnown::NodeInfoController < ApplicationController
def discovery
expires_in 3.days, public: true
render json: {
links: [
rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
href: node_info_url
],
}
end
def nodeinfo
expires_in 30.minutes, public: true
render json: {
version: "2.1",
software: software_info,
protocols: %i[],
services: {
inbound: inbound_services,
outbound: outbound_services,
},
usage: usage_stats,
# We don't implement this so we can always return true for now
openRegistrations: true,
metadata: {},
}
end
private
def software_info
{
name: "Retrospring",
version: Retrospring::Version.to_s,
repository: "https://github.com/Retrospring/retrospring",
}
end
def usage_stats
{
users: {
total: User.count,
},
}
end
def inbound_services = []
def outbound_services = []
end

View file

@ -177,11 +177,8 @@ Rails.application.routes.draw do
namespace :well_known, path: "/.well-known" do
get "/change-password", to: redirect("/settings/account")
get "/nodeinfo", to: "node_info#discovery"
end
get "/nodeinfo/2.1", to: "well_known/node_info#nodeinfo", as: :node_info
get "/modal/close", to: "modal#close", as: :modal_close
puts "processing time of routes.rb: #{"#{(Time.zone.now - start).round(3).to_s.ljust(5, '0')}s".light_green}"

View file

@ -1,66 +0,0 @@
# frozen_string_literal: true
require "rails_helper"
describe WellKnown::NodeInfoController do
describe "#discovery" do
subject { get :discovery }
it "returns the expected response" do
subject
parsed = JSON.parse(response.body)
expect(parsed).to eq({
"links" => [
{
"rel" => "http://nodeinfo.diaspora.software/ns/schema/2.1",
"href" => "http://test.host/nodeinfo/2.1",
}
],
})
end
end
describe "#nodeinfo" do
subject { get :nodeinfo }
it "is valid as specified by the schema" do
get(:discovery)
schema = response.body
subject
parsed = JSON.parse(response.body)
messages = JSON::Validator.fully_validate(schema, parsed)
expect(messages).to be_empty
end
context "version is 2023.0102.1" do
before do
allow(Retrospring::Version).to receive(:to_s).and_return("2023.0102.1")
end
it "returns the correct version" do
subject
parsed = JSON.parse(response.body)
expect(parsed["software"]).to eq({
"name" => "Retrospring",
"version" => "2023.0102.1",
"repository" => "https://github.com/Retrospring/retrospring",
})
end
end
context "site has users" do
let(:num_users) { rand(10..50) }
before do
FactoryBot.create_list(:user, num_users)
end
it "includes the correct user count" do
subject
parsed = JSON.parse(response.body)
expect(parsed.dig("usage", "users", "total")).to eq(num_users)
end
end
end
end