make payment.extra non-optional
this makes handling in tasks.py so much easier
This commit is contained in:
parent
301a784e95
commit
191ad1e224
|
@ -88,7 +88,7 @@ class Payment(BaseModel):
|
|||
preimage: str
|
||||
payment_hash: str
|
||||
expiry: Optional[float]
|
||||
extra: Optional[Dict] = {}
|
||||
extra: Dict = {}
|
||||
wallet_id: str
|
||||
webhook: Optional[str]
|
||||
webhook_status: Optional[int]
|
||||
|
|
|
@ -28,6 +28,7 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if payment.extra and not payment.extra.get("tag") == "cashu":
|
||||
if payment.extra.get("tag") != "cashu":
|
||||
return
|
||||
|
||||
return
|
||||
|
|
|
@ -24,12 +24,12 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
webhook = None
|
||||
data = None
|
||||
if not payment.extra or payment.extra.get("tag") != "copilot":
|
||||
if payment.extra.get("tag") != "copilot":
|
||||
# not an copilot invoice
|
||||
return
|
||||
|
||||
webhook = None
|
||||
data = None
|
||||
copilot = await get_copilot(payment.extra.get("copilotid", -1))
|
||||
|
||||
if not copilot:
|
||||
|
|
|
@ -25,9 +25,6 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if not payment.extra:
|
||||
return
|
||||
|
||||
if payment.extra.get("tag") != "invoices":
|
||||
return
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if payment.extra:
|
||||
if payment.extra.get("tag") != "jukebox":
|
||||
# not a jukebox invoice
|
||||
return
|
||||
await update_jukebox_payment(payment.payment_hash, paid=True)
|
||||
if payment.extra.get("tag") != "jukebox":
|
||||
# not a jukebox invoice
|
||||
return
|
||||
|
||||
await update_jukebox_payment(payment.payment_hash, paid=True)
|
||||
|
|
|
@ -19,7 +19,7 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if not payment.extra or payment.extra.get("tag") != "lnticket":
|
||||
if payment.extra.get("tag") != "lnticket":
|
||||
# not a lnticket invoice
|
||||
return
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment):
|
||||
if not payment.extra or payment.extra.get("tag") != "lnurlp":
|
||||
if payment.extra.get("tag") != "lnurlp":
|
||||
return
|
||||
|
||||
if payment.extra.get("wh_status"):
|
||||
|
|
|
@ -23,9 +23,6 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if not payment.extra:
|
||||
return
|
||||
|
||||
if payment.extra.get("tag") != "market":
|
||||
return
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if not payment.extra:
|
||||
return
|
||||
if payment.extra.get("tag") != "nostrnip5":
|
||||
return
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ async def wait_for_paid_invoices():
|
|||
|
||||
async def on_invoice_paid(payment: Payment):
|
||||
# (avoid loops)
|
||||
if payment.extra and payment.extra.get("tag") == "scrubed":
|
||||
if payment.extra.get("tag") == "scrubed":
|
||||
# already scrubbed
|
||||
return
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if not payment.extra or payment.extra.get("tag") == "splitpayments":
|
||||
if payment.extra.get("tag") == "splitpayments":
|
||||
# already a splitted payment, ignore
|
||||
return
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if not payment.extra or payment.extra.get("tag") != "lnsubdomain":
|
||||
if payment.extra.get("tag") != "lnsubdomain":
|
||||
# not an lnurlp invoice
|
||||
return
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if not payment.extra:
|
||||
return
|
||||
if payment.extra.get("tag") != "tpos":
|
||||
return
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user