Add own relay to NIP-05 relay list if configured

This commit is contained in:
2024-06-19 20:06:07 +02:00
parent 926dc06294
commit 87d900b627
2 changed files with 32 additions and 3 deletions

View File

@@ -45,6 +45,27 @@ RSpec.describe "Well-known URLs", type: :request do
expect(res["names"].keys.size).to eq(1)
expect(res["names"]["bobdylan"]).to eq(user.nostr_pubkey)
end
context "without relay configured" do
it "does not include a recommended relay" do
get "/.well-known/nostr.json?name=bobdylan"
res = JSON.parse(response.body)
expect(res["relays"]).to be_nil
end
end
context "with relay configured" do
before do
Setting.nostr_relay_url = "wss://nostr.kosmos.org"
end
it "includes a recommended relay" do
get "/.well-known/nostr.json?name=bobdylan"
res = JSON.parse(response.body)
expect(res["relays"][user.nostr_pubkey].length).to eq(1)
expect(res["relays"][user.nostr_pubkey].first).to eq("wss://nostr.kosmos.org")
end
end
end
end
end