2020-09-13 21:31:05 -03:00
|
|
|
from quart import g, abort, render_template
|
2020-08-28 23:03:12 -03:00
|
|
|
from http import HTTPStatus
|
|
|
|
|
|
|
|
from lnbits.decorators import check_user_exists, validate_uuids
|
|
|
|
|
2020-11-21 18:04:39 -03:00
|
|
|
from . import lnurlp_ext
|
2020-08-28 23:03:12 -03:00
|
|
|
from .crud import get_pay_link
|
|
|
|
|
|
|
|
|
|
|
|
@lnurlp_ext.route("/")
|
|
|
|
@validate_uuids(["usr"], required=True)
|
|
|
|
@check_user_exists()
|
2020-09-13 21:31:05 -03:00
|
|
|
async def index():
|
|
|
|
return await render_template("lnurlp/index.html", user=g.user)
|
2020-08-28 23:03:12 -03:00
|
|
|
|
|
|
|
|
|
|
|
@lnurlp_ext.route("/<link_id>")
|
2020-09-13 21:31:05 -03:00
|
|
|
async def display(link_id):
|
2020-11-21 18:04:39 -03:00
|
|
|
link = await get_pay_link(link_id)
|
|
|
|
if not link:
|
|
|
|
abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.")
|
|
|
|
|
2020-09-13 21:31:05 -03:00
|
|
|
return await render_template("lnurlp/display.html", link=link)
|
2020-08-28 23:03:12 -03:00
|
|
|
|
|
|
|
|
|
|
|
@lnurlp_ext.route("/print/<link_id>")
|
2020-09-13 21:31:05 -03:00
|
|
|
async def print_qr(link_id):
|
2020-11-21 18:04:39 -03:00
|
|
|
link = await get_pay_link(link_id)
|
|
|
|
if not link:
|
|
|
|
abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.")
|
|
|
|
|
2020-09-13 21:31:05 -03:00
|
|
|
return await render_template("lnurlp/print_qr.html", link=link)
|