diff --git a/app/services/nostr_manager/publish_zap_receipt.rb b/app/services/nostr_manager/publish_zap_receipt.rb index 22a7714..b529c41 100644 --- a/app/services/nostr_manager/publish_zap_receipt.rb +++ b/app/services/nostr_manager/publish_zap_receipt.rb @@ -6,8 +6,13 @@ module NostrManager def call tags = parse_tags(@zap.request_event.tags) + relays = tags[:relays].take(Setting.nostr_zaps_relay_limit) - tags[:relays].take(Setting.nostr_zaps_relay_limit).each do |relay_url| + if Setting.nostr_relay_url.present? + relays << Setting.nostr_relay_url + end + + relays.uniq.each do |relay_url| if @delayed NostrPublishEventJob.perform_later(event: @zap.receipt, relay_url: relay_url) else diff --git a/spec/services/nostr_manager/publish_zap_receipt_spec.rb b/spec/services/nostr_manager/publish_zap_receipt_spec.rb index 452e34e..5136af9 100644 --- a/spec/services/nostr_manager/publish_zap_receipt_spec.rb +++ b/spec/services/nostr_manager/publish_zap_receipt_spec.rb @@ -35,6 +35,19 @@ RSpec.describe NostrManager::PublishZapReceipt, type: :model do described_class.call(zap: zap) end + + context "with own relay configured" do + before do + Setting.nostr_relay_url = "wss://foobar.kosmos.org" + end + + it "also publishes the receipt to our own relay" do + expect(NostrPublishEventJob).to receive(:perform_later) + .exactly(13).times.and_return(true) + + described_class.call(zap: zap) + end + end end end end