Respect new Lightning notification settings
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 4s

This commit is contained in:
2024-06-01 17:24:53 +02:00
parent 5348a229a6
commit 1685d6ecf8
2 changed files with 53 additions and 5 deletions

View File

@@ -101,6 +101,34 @@ RSpec.describe "Webhooks", type: :request do
expect(args[3]["params"]["amount_sats"]).to eq(12300)
end
end
describe "minimum threshold amount not reached" do
before do
user.update! preferences: {
lightning_notify_sats_received: "xmpp",
lightning_notify_min_sats: 21000
}
end
it "does not send a notification" do
post "/webhooks/lndhub", params: payload.to_json
expect(enqueued_jobs.size).to eq(0)
end
end
describe "no memo/description/message" do
before do
user.update! preferences: {
lightning_notify_sats_received: "xmpp",
lightning_notify_only_with_message: true
}
end
it "does not send a notification" do
post "/webhooks/lndhub", params: payload.merge({ memo: "" }).to_json
expect(enqueued_jobs.size).to eq(0)
end
end
end
describe "Valid payload for zap transaction" do
@@ -149,6 +177,17 @@ RSpec.describe "Webhooks", type: :request do
expect(NostrManager::PublishZapReceipt).to receive(:call).with(zap: zap)
post "/webhooks/lndhub", params: payload.to_json
end
context "with notifications disabled for zaps" do
before do
user.update! preferences: { lightning_notify_zap_received: "disabled" }
end
it "does not send a notification" do
post "/webhooks/lndhub", params: payload.to_json
expect(enqueued_jobs.size).to eq(0)
end
end
end
end
end