Skip to content

Commit

Permalink
Return zap request
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Mar 25, 2024
1 parent 6226b5e commit e5ef1ae
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,25 @@ async fn notify_user(
invoice: &Invoice,
user: AppUser,
) -> Result<()> {
let zap = state.db.get_zap_by_id(invoice.id)?;

let dm = nostr
.send_direct_msg(
XOnlyPublicKey::from_str(&user.pubkey)?,
json!({
"federation_id": invoice.federation_id,
"tweak_index": invoice.user_invoice_index,
"amount": invoice.amount,
"zap_request": zap.as_ref().map(|z| z.request.clone()),
})
.to_string(),
None,
)
.await?;

// Send zap if needed
if let Some(zap) = state.db.get_zap_by_id(invoice.id)? {
let request = Event::from_json(zap.request.clone())?;
if let Some(zap) = zap {
let request = Event::from_json(&zap.request)?;
let event = create_zap_event(request, invoice.amount as u64, nostr.keys().await)?;

let event_id = nostr.send_event(event).await?;
Expand Down

0 comments on commit e5ef1ae

Please sign in to comment.