feat: improve codequality and CI (#25)
* feat: improve codequality and CI
This commit is contained in:
parent
28121184c3
commit
cc6752003a
28 changed files with 3114 additions and 292 deletions
24
tasks.py
24
tasks.py
|
|
@ -1,12 +1,11 @@
|
|||
import asyncio
|
||||
import json
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from lnbits.core.models import Payment
|
||||
from lnbits.core.services import websocket_updater
|
||||
from lnbits.helpers import get_current_extension_name
|
||||
from lnbits.tasks import register_invoice_listener
|
||||
from loguru import logger
|
||||
|
||||
from .crud import create_account, get_account, update_account
|
||||
from .models import NostrAccount
|
||||
|
|
@ -27,34 +26,41 @@ async def on_invoice_paid(payment: Payment):
|
|||
|
||||
relay_id = payment.extra.get("relay_id")
|
||||
pubkey = payment.extra.get("pubkey")
|
||||
hash = payment.payment_hash
|
||||
payment_hash = payment.payment_hash
|
||||
|
||||
if not relay_id or not pubkey:
|
||||
message = f"Invoice extra data missing for 'relay_id' and 'pubkey'. Payment hash: {hash}"
|
||||
message = (
|
||||
"Invoice extra data missing for 'relay_id' and 'pubkey'. "
|
||||
f"Payment hash: {payment_hash}"
|
||||
)
|
||||
logger.warning(message)
|
||||
await websocket_updater(hash, json.dumps({"success": False, "message": message}))
|
||||
await websocket_updater(
|
||||
payment_hash, json.dumps({"success": False, "message": message})
|
||||
)
|
||||
return
|
||||
|
||||
action = payment.extra.get("action")
|
||||
if action == "join":
|
||||
await invoice_paid_to_join(relay_id, pubkey, payment.amount)
|
||||
await websocket_updater(hash, json.dumps({"success": True}))
|
||||
await websocket_updater(payment_hash, json.dumps({"success": True}))
|
||||
return
|
||||
|
||||
if action == "storage":
|
||||
storage_to_buy = payment.extra.get("storage_to_buy")
|
||||
if not storage_to_buy:
|
||||
message = (
|
||||
f"Invoice extra data missing for 'storage_to_buy'. Payment hash: {hash}"
|
||||
"Invoice extra data missing for 'storage_to_buy'. "
|
||||
f"Payment hash: {payment_hash}"
|
||||
)
|
||||
logger.warning(message)
|
||||
return
|
||||
await invoice_paid_for_storage(relay_id, pubkey, storage_to_buy, payment.amount)
|
||||
await websocket_updater(hash, json.dumps({"success": True}))
|
||||
await websocket_updater(payment_hash, json.dumps({"success": True}))
|
||||
return
|
||||
|
||||
await websocket_updater(
|
||||
hash, json.dumps({"success": False, "message": f"Bad action name: '{action}'"})
|
||||
payment_hash,
|
||||
json.dumps({"success": False, "message": f"Bad action name: '{action}'"}),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue