Merge branch 'master' into StreamerCopilot
This commit is contained in:
commit
2e8b2e5ac8
5 changed files with 22 additions and 20 deletions
1
Pipfile
1
Pipfile
|
|
@ -17,7 +17,6 @@ shortuuid = "*"
|
||||||
quart = "*"
|
quart = "*"
|
||||||
quart-cors = "*"
|
quart-cors = "*"
|
||||||
quart-compress = "*"
|
quart-compress = "*"
|
||||||
secure = "*"
|
|
||||||
typing-extensions = "*"
|
typing-extensions = "*"
|
||||||
httpx = "*"
|
httpx = "*"
|
||||||
quart-trio = "*"
|
quart-trio = "*"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ from quart import g
|
||||||
from quart_trio import QuartTrio
|
from quart_trio import QuartTrio
|
||||||
from quart_cors import cors # type: ignore
|
from quart_cors import cors # type: ignore
|
||||||
from quart_compress import Compress # type: ignore
|
from quart_compress import Compress # type: ignore
|
||||||
from secure import SecureHeaders # type: ignore
|
|
||||||
|
|
||||||
from .commands import db_migrate, handle_assets
|
from .commands import db_migrate, handle_assets
|
||||||
from .core import core_app
|
from .core import core_app
|
||||||
|
|
@ -27,8 +26,6 @@ from .tasks import (
|
||||||
)
|
)
|
||||||
from .settings import WALLET
|
from .settings import WALLET
|
||||||
|
|
||||||
secure_headers = SecureHeaders(hsts=False, xfo=False)
|
|
||||||
|
|
||||||
|
|
||||||
def create_app(config_object="lnbits.settings") -> QuartTrio:
|
def create_app(config_object="lnbits.settings") -> QuartTrio:
|
||||||
"""Create application factory.
|
"""Create application factory.
|
||||||
|
|
@ -46,7 +43,6 @@ def create_app(config_object="lnbits.settings") -> QuartTrio:
|
||||||
register_blueprints(app)
|
register_blueprints(app)
|
||||||
register_filters(app)
|
register_filters(app)
|
||||||
register_commands(app)
|
register_commands(app)
|
||||||
register_request_hooks(app)
|
|
||||||
register_async_tasks(app)
|
register_async_tasks(app)
|
||||||
register_exception_handlers(app)
|
register_exception_handlers(app)
|
||||||
|
|
||||||
|
|
@ -112,15 +108,6 @@ def register_filters(app: QuartTrio):
|
||||||
app.jinja_env.globals["EXTENSIONS"] = get_valid_extensions()
|
app.jinja_env.globals["EXTENSIONS"] = get_valid_extensions()
|
||||||
|
|
||||||
|
|
||||||
def register_request_hooks(app: QuartTrio):
|
|
||||||
"""Open the core db for each request so everything happens in a big transaction"""
|
|
||||||
|
|
||||||
@app.after_request
|
|
||||||
async def set_secure_headers(response):
|
|
||||||
secure_headers.quart(response)
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
def register_async_tasks(app):
|
def register_async_tasks(app):
|
||||||
@app.route("/wallet/webhook", methods=["GET", "POST", "PUT", "PATCH", "DELETE"])
|
@app.route("/wallet/webhook", methods=["GET", "POST", "PUT", "PATCH", "DELETE"])
|
||||||
async def webhook_listener():
|
async def webhook_listener():
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,24 @@ async def api_public_payment_longpolling(payment_hash):
|
||||||
print("adding standalone invoice listener", payment_hash, send_payment)
|
print("adding standalone invoice listener", payment_hash, send_payment)
|
||||||
api_invoice_listeners.append(send_payment)
|
api_invoice_listeners.append(send_payment)
|
||||||
|
|
||||||
async for payment in receive_payment:
|
response = None
|
||||||
if payment.payment_hash == payment_hash:
|
|
||||||
return jsonify({"status": "paid"}), HTTPStatus.OK
|
async def payment_info_receiver(cancel_scope):
|
||||||
|
async for payment in receive_payment:
|
||||||
|
if payment.payment_hash == payment_hash:
|
||||||
|
nonlocal response
|
||||||
|
response = (jsonify({"status": "paid"}), HTTPStatus.OK)
|
||||||
|
cancel_scope.cancel()
|
||||||
|
|
||||||
|
async def timeouter(cancel_scope):
|
||||||
|
await trio.sleep(45)
|
||||||
|
cancel_scope.cancel()
|
||||||
|
|
||||||
|
async with trio.open_nursery() as nursery:
|
||||||
|
nursery.start_soon(payment_info_receiver, nursery.cancel_scope)
|
||||||
|
nursery.start_soon(timeouter, nursery.cancel_scope)
|
||||||
|
|
||||||
|
if response:
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
return jsonify({"message": "timeout"}), HTTPStatus.REQUEST_TIMEOUT
|
||||||
|
|
|
||||||
|
|
@ -317,9 +317,8 @@
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
self.tickets = response.data
|
self.tickets = response.data
|
||||||
.map(function (obj) {
|
.map(function (obj) {
|
||||||
if (obj.paid){
|
if (!obj?.paid) return
|
||||||
return mapLNTicket(obj)
|
return mapLNTicket(obj)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.filter(v => v)
|
.filter(v => v)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ quart-cors==0.4.0
|
||||||
quart-trio==0.7.0
|
quart-trio==0.7.0
|
||||||
represent==1.6.0.post0
|
represent==1.6.0.post0
|
||||||
rfc3986==1.4.0
|
rfc3986==1.4.0
|
||||||
secure==0.2.1
|
|
||||||
shortuuid==1.0.1
|
shortuuid==1.0.1
|
||||||
six==1.15.0
|
six==1.15.0
|
||||||
sniffio==1.2.0
|
sniffio==1.2.0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue