Merge branch 'feature/own_relay' into live
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
090affd304
@ -9,15 +9,13 @@ class WellKnownController < ApplicationController
|
||||
if params[:name] == "_"
|
||||
# pubkey for the primary domain without a username (e.g. kosmos.org)
|
||||
res = { names: { "_": Setting.nostr_public_key } }
|
||||
res[:relays] = { "_" => [ relay_url ] } if relay_url
|
||||
else
|
||||
@user = User.where(cn: params[:name], ou: domain).first
|
||||
http_status :not_found and return if @user.nil? || @user.nostr_pubkey.blank?
|
||||
|
||||
res = { names: { @user.cn => @user.nostr_pubkey } }
|
||||
end
|
||||
|
||||
if relay_url
|
||||
res[:relays] = { @user.nostr_pubkey => [ relay_url ] }
|
||||
res[:relays] = { @user.nostr_pubkey => [ relay_url ] } if relay_url
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -75,6 +75,19 @@ RSpec.describe "Well-known URLs", type: :request do
|
||||
expect(res["names"]["_"]).to eq(Setting.nostr_public_key)
|
||||
end
|
||||
|
||||
context "with relay configured" do
|
||||
before do
|
||||
Setting.nostr_relay_url = "wss://nostr.kosmos.org"
|
||||
end
|
||||
|
||||
it "returns the pubkey and relay" do
|
||||
get "/.well-known/nostr.json?name=_"
|
||||
res = JSON.parse(response.body)
|
||||
expect(res["relays"]["_"].length).to eq(1)
|
||||
expect(res["relays"]["_"].first).to eq("wss://nostr.kosmos.org")
|
||||
end
|
||||
end
|
||||
|
||||
context "nostr service integration not enabled" do
|
||||
before do
|
||||
Setting.nostr_enabled = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user