Skip to content

Commit

Permalink
chore: DRY up dtag usage
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Jan 18, 2024
1 parent 09ae1fb commit b1a43fe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions handle_multi_pay_invoice_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,19 @@ func (svc *Service) HandleMultiPayInvoiceEvent(ctx context.Context, sub *nostr.S
}).Errorf("Failed to process event: %v", err)
return
}
// TODO: Decide what to do if id is empty
dTag := []string{"a", fmt.Sprintf("%d:%s:%s", NIP_47_RESPONSE_KIND, event.PubKey, invoiceInfo.Id)}
resp.Tags = append(resp.Tags, dTag)
svc.PublishEvent(ctx, sub, event, resp)
return
}

id := invoiceInfo.Id
if id == "" {
id = paymentRequest.PaymentHash
}
dTag := []string{"a", fmt.Sprintf("%d:%s:%s", NIP_47_RESPONSE_KIND, event.PubKey, id)}

hasPermission, code, message := svc.hasPermission(&app, event, request.Method, paymentRequest.MSatoshi)

if !hasPermission {
Expand All @@ -108,7 +115,6 @@ func (svc *Service) HandleMultiPayInvoiceEvent(ctx context.Context, sub *nostr.S
}).Errorf("Failed to process event: %v", err)
return
}
dTag := []string{"a", fmt.Sprintf("%d:%s:%s", NIP_47_RESPONSE_KIND, event.PubKey, invoiceInfo.Id)}
resp.Tags = append(resp.Tags, dTag)
svc.PublishEvent(ctx, sub, event, resp)
return
Expand Down Expand Up @@ -161,7 +167,6 @@ func (svc *Service) HandleMultiPayInvoiceEvent(ctx context.Context, sub *nostr.S
}).Errorf("Failed to process event: %v", err)
return
}
dTag := []string{"a", fmt.Sprintf("%d:%s:%s", NIP_47_RESPONSE_KIND, event.PubKey, invoiceInfo.Id)}
resp.Tags = append(resp.Tags, dTag)
svc.PublishEvent(ctx, sub, event, resp)
return
Expand All @@ -186,7 +191,6 @@ func (svc *Service) HandleMultiPayInvoiceEvent(ctx context.Context, sub *nostr.S
}).Errorf("Failed to process event: %v", err)
return
}
dTag := []string{"a", fmt.Sprintf("%d:%s:%s", NIP_47_RESPONSE_KIND, event.PubKey, invoiceInfo.Id)}
resp.Tags = append(resp.Tags, dTag)
svc.PublishEvent(ctx, sub, event, resp)
}(invoiceInfo)
Expand Down

0 comments on commit b1a43fe

Please sign in to comment.