WIP Check for zaps, send zap receipt on incoming zap tx

This commit is contained in:
2024-04-21 10:35:30 +02:00
parent b36baf26eb
commit e27c64b5f1
4 changed files with 70 additions and 9 deletions

View File

@@ -7,6 +7,12 @@ class WebhooksController < ApplicationController
def lndhub
@user = User.find_by!(ln_account: @payload[:user_login])
if @zap_request = fetch_nostr_event_from_description
NostrManager::PublishZapReceipt.call(
user: @user, zap_request: @zap_request
)
end
send_notifications
head :ok
@@ -21,12 +27,17 @@ class WebhooksController < ApplicationController
end
def process_payload
begin
@payload = JSON.parse(request.body.read, symbolize_names: true)
head :no_content and return unless @payload[:type] == "incoming"
rescue
head :unprocessable_entity and return
end
@payload = JSON.parse(request.body.read, symbolize_names: true)
head :no_content and return unless @payload[:type] == "incoming"
rescue
head :unprocessable_entity and return
end
def fetch_nostr_event_from_description
memo_json = JSON.parse(@payload[:memo])
Nostr::Event.new(**memo_json.to_h.symbolize_keys)
rescue
nil
end
def send_notifications