Improve nostr settings, fix allowsNostr property name
This commit is contained in:
parent
c6c5d80fb4
commit
2d1ff29eca
@ -18,8 +18,8 @@ class LnurlpayController < ApplicationController
|
|||||||
commentAllowed: MAX_COMMENT_CHARS
|
commentAllowed: MAX_COMMENT_CHARS
|
||||||
}
|
}
|
||||||
|
|
||||||
if Setting.nostr_enabled? && Setting.nostr_private_key.present?
|
if Setting.nostr_enabled?
|
||||||
res[:allows_nostr] = true
|
res[:allowsNostr] = true
|
||||||
res[:nostrPubkey] = Setting.nostr_public_key
|
res[:nostrPubkey] = Setting.nostr_public_key
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class LnurlpayController < ApplicationController
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:nostr].present?# TODO && Setting.nostr_enabled?
|
if params[:nostr].present? && Setting.nostr_enabled?
|
||||||
handle_zap_request amount, params[:nostr], params[:lnurl]
|
handle_zap_request amount, params[:nostr], params[:lnurl]
|
||||||
else
|
else
|
||||||
handle_pay_request address, amount, comment
|
handle_pay_request address, amount, comment
|
||||||
|
@ -160,7 +160,8 @@ class Setting < RailsSettings::Base
|
|||||||
# Nostr
|
# Nostr
|
||||||
#
|
#
|
||||||
|
|
||||||
field :nostr_enabled, type: :boolean, default: false
|
field :nostr_enabled, type: :boolean,
|
||||||
|
default: ENV["NOSTR_PRIVATE_KEY"].present?
|
||||||
|
|
||||||
field :nostr_private_key, type: :string,
|
field :nostr_private_key, type: :string,
|
||||||
default: ENV["NOSTR_PRIVATE_KEY"].presence
|
default: ENV["NOSTR_PRIVATE_KEY"].presence
|
||||||
|
@ -29,6 +29,7 @@ RSpec.describe "/lnurlpay", type: :request do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
login_as user, :scope => :user
|
login_as user, :scope => :user
|
||||||
|
Setting.nostr_enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /.well-known/lnurlp/:username" do
|
describe "GET /.well-known/lnurlp/:username" do
|
||||||
@ -44,6 +45,21 @@ RSpec.describe "/lnurlpay", type: :request do
|
|||||||
expect(res["minSendable"]).to be_a(Integer)
|
expect(res["minSendable"]).to be_a(Integer)
|
||||||
expect(res["maxSendable"]).to be_a(Integer)
|
expect(res["maxSendable"]).to be_a(Integer)
|
||||||
expect(res["commentAllowed"]).to be_a(Integer)
|
expect(res["commentAllowed"]).to be_a(Integer)
|
||||||
|
expect(res["allowsNostr"]).to be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with support for nostr zaps" do
|
||||||
|
before do
|
||||||
|
Setting.nostr_enabled = true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns NIP-57 properties" do
|
||||||
|
get lightning_address_path(username: "satoshi")
|
||||||
|
|
||||||
|
res = JSON.parse(response.body)
|
||||||
|
expect(res["allowsNostr"]).to be(true)
|
||||||
|
expect(res["nostrPubkey"]).to eq(Setting.nostr_public_key)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -104,6 +120,10 @@ RSpec.describe "/lnurlpay", type: :request do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "zap request" do
|
context "zap request" do
|
||||||
|
before do
|
||||||
|
Setting.nostr_enabled = true
|
||||||
|
end
|
||||||
|
|
||||||
describe "with invalid request event" do
|
describe "with invalid request event" do
|
||||||
it "returns an error" do
|
it "returns an error" do
|
||||||
get lnurlpay_invoice_path(username: "satoshi", params: {
|
get lnurlpay_invoice_path(username: "satoshi", params: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user