From 8b52dfc30727c21ada1cde16dd120a22677b3786 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Tue, 20 Apr 2021 00:37:51 +0100 Subject: [PATCH] added updater function --- lnbits/extensions/copilot/tasks.py | 6 ++---- lnbits/extensions/copilot/views.py | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lnbits/extensions/copilot/tasks.py b/lnbits/extensions/copilot/tasks.py index 6547aa5f..29ec62dc 100644 --- a/lnbits/extensions/copilot/tasks.py +++ b/lnbits/extensions/copilot/tasks.py @@ -7,6 +7,7 @@ from lnbits.core.models import Payment from lnbits.tasks import register_invoice_listener from .crud import get_copilot +from .views import updater import shortuuid async def register_listeners(): @@ -69,10 +70,7 @@ async def on_invoice_paid(payment: Payment) -> None: await mark_webhook_sent(payment, r.status_code) except (httpx.ConnectError, httpx.RequestError): await mark_webhook_sent(payment, -1) - global connected_websockets - connected_websockets[copilot.id] = ( - shortuuid.uuid() + "-" + data + "-" + payment.extra.get("comment") - ) + await updater(data, payment.extra.get("comment"), copilot.id) async def mark_webhook_sent(payment: Payment, status: int) -> None: diff --git a/lnbits/extensions/copilot/views.py b/lnbits/extensions/copilot/views.py index ee5254ce..a424b4b2 100644 --- a/lnbits/extensions/copilot/views.py +++ b/lnbits/extensions/copilot/views.py @@ -64,3 +64,9 @@ async def panel(copilot_id): HTTPStatus.NOT_FOUND, "Copilot link does not exist." ) return await render_template("copilot/panel.html", copilot=copilot) + +async def updater(data, comment, copilot): + global connected_websockets + connected_websockets[copilot] = ( + shortuuid.uuid() + "-" + data + "-" + comment + ) \ No newline at end of file