changed name to myextension
This commit is contained in:
parent
ba7e11e30d
commit
0711f583d6
16 changed files with 221 additions and 225 deletions
22
tasks.py
22
tasks.py
|
|
@ -7,7 +7,7 @@ from lnbits.core.services import create_invoice, pay_invoice, websocketUpdater
|
|||
from lnbits.helpers import get_current_extension_name
|
||||
from lnbits.tasks import register_invoice_listener
|
||||
|
||||
from .crud import get_temp
|
||||
from .crud import get_myextension
|
||||
|
||||
|
||||
#######################################
|
||||
|
|
@ -29,31 +29,31 @@ async def wait_for_paid_invoices():
|
|||
# do somethhing when an invoice related top this extension is paid
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if payment.extra.get("tag") != "temp":
|
||||
if payment.extra.get("tag") != "myextension":
|
||||
return
|
||||
|
||||
temp_id = payment.extra.get("tempId")
|
||||
assert temp_id
|
||||
myextension_id = payment.extra.get("tempId")
|
||||
assert myextension_id
|
||||
|
||||
temp = await get_temp(temp_id)
|
||||
assert temp
|
||||
myextension = await get_myextension(myextension_id)
|
||||
assert myextension
|
||||
|
||||
# update something
|
||||
|
||||
data_to_update = {
|
||||
"total": temp.total + payment.amount
|
||||
"total": myextension.total + payment.amount
|
||||
}
|
||||
|
||||
await update_temp(temp_id=temp_id, **data_to_update.dict())
|
||||
await update_myextension(myextension_id=myextension_id, **data_to_update.dict())
|
||||
|
||||
|
||||
# here we could send some data to a websocket on wss://<your-lnbits>/api/v1/ws/<temp_id>
|
||||
# here we could send some data to a websocket on wss://<your-lnbits>/api/v1/ws/<myextension_id>
|
||||
|
||||
some_payment_data = {
|
||||
"name": temp.name,
|
||||
"name": myextension.name,
|
||||
"amount": payment.amount,
|
||||
"fee": payment.fee,
|
||||
"checking_id": payment.checking_id
|
||||
}
|
||||
|
||||
await websocketUpdater(temp_id, str(some_payment_data))
|
||||
await websocketUpdater(myextension_id, str(some_payment_data))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue