WIP Check for zaps, send zap receipt on incoming zap tx
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user