Lnurl all-father, please let this work
This commit is contained in:
parent
9ec3fea73c
commit
7b4bf3cdc0
3 changed files with 36 additions and 43 deletions
|
|
@ -66,10 +66,9 @@ async def lnurl_callback(cp_id):
|
||||||
wallet_id=cp.wallet,
|
wallet_id=cp.wallet,
|
||||||
amount=int(amount_received / 1000),
|
amount=int(amount_received / 1000),
|
||||||
memo=cp.lnurl_title,
|
memo=cp.lnurl_title,
|
||||||
webhook="/copilot/api/v1/copilot/hook/" + cp_id,
|
webhook=url_for("copilot.api_copilot_hooker", cp_id=cp_id, amount=int(amount_received / 1000), _external=True),
|
||||||
description_hash=hashlib.sha256((cp.lnurl_title).encode("utf-8")).digest(),
|
description_hash=hashlib.sha256((cp.lnurl_title).encode("utf-8")).digest(),
|
||||||
extra={"tag": "copilot", "comment": comment},
|
extra={"tag": "copilot", "comment": comment},
|
||||||
)
|
)
|
||||||
print(jsonify(pr=payment_request, success_action=None, routes=[], disposable=None))
|
|
||||||
print(["pr"=payment_request, "success_action"=None, "routes"=[], "disposable"=None])
|
return jsonify(pr=payment_request, success_action=None, routes=[])
|
||||||
return jsonify(pr=payment_request, success_action=None, routes=[], disposable=None)
|
|
||||||
|
|
@ -22,7 +22,6 @@ async def ws_panel(copilot_id):
|
||||||
data = await websocket.receive()
|
data = await websocket.receive()
|
||||||
connected_websockets[copilot_id] = shortuuid.uuid() + "-" + data
|
connected_websockets[copilot_id] = shortuuid.uuid() + "-" + data
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.websocket("/ws/compose/<copilot_id>")
|
@copilot_ext.websocket("/ws/compose/<copilot_id>")
|
||||||
async def ws_compose(copilot_id):
|
async def ws_compose(copilot_id):
|
||||||
global connected_websockets
|
global connected_websockets
|
||||||
|
|
@ -61,3 +60,35 @@ async def panel(copilot_id):
|
||||||
HTTPStatus.NOT_FOUND, "Copilot link does not exist."
|
HTTPStatus.NOT_FOUND, "Copilot link does not exist."
|
||||||
)
|
)
|
||||||
return await render_template("copilot/panel.html", copilot=copilot)
|
return await render_template("copilot/panel.html", copilot=copilot)
|
||||||
|
|
||||||
|
|
||||||
|
@copilot_ext.route("/api/v1/copilot/hook/<copilot_id>/<amount>", methods=["GET"])
|
||||||
|
async def api_copilot_hooker(copilot_id, amount):
|
||||||
|
copilot = await get_copilot(copilot_id)
|
||||||
|
|
||||||
|
if not copilot:
|
||||||
|
return (
|
||||||
|
jsonify({"message": "Copilot link link does not exist."}),
|
||||||
|
HTTPStatus.NOT_FOUND,
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
copilot.animation1threshold
|
||||||
|
and int(amount) > copilot.animation1threshold
|
||||||
|
):
|
||||||
|
data = copilot.animation1
|
||||||
|
if (
|
||||||
|
copilot.animation2threshold
|
||||||
|
and int(amount) > copilot.animation2threshold
|
||||||
|
):
|
||||||
|
data = copilot.animation2
|
||||||
|
if (
|
||||||
|
copilot.animation3threshold
|
||||||
|
and int(amount) > copilot.animation3threshold
|
||||||
|
):
|
||||||
|
data = copilot.animation3
|
||||||
|
async with websocket(
|
||||||
|
"/ws/compose/" + copilot_id
|
||||||
|
) as the_websocket:
|
||||||
|
await the_websocket.send(data)
|
||||||
|
|
||||||
|
return "", HTTPStatus.OK
|
||||||
|
|
@ -91,40 +91,3 @@ async def api_copilot_delete(copilot_id):
|
||||||
await delete_copilot(copilot_id)
|
await delete_copilot(copilot_id)
|
||||||
|
|
||||||
return "", HTTPStatus.NO_CONTENT
|
return "", HTTPStatus.NO_CONTENT
|
||||||
|
|
||||||
|
|
||||||
#############################PAYMENTHOOKER##########################
|
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.route("/api/v1/copilot/hook/<copilot_id>", methods=["POST"])
|
|
||||||
async def api_copilot_hooker(copilot_id, trigger):
|
|
||||||
copilot = await get_copilot(copilot_id)
|
|
||||||
|
|
||||||
if not copilot:
|
|
||||||
return (
|
|
||||||
jsonify({"message": "Copilot link link does not exist."}),
|
|
||||||
HTTPStatus.NOT_FOUND,
|
|
||||||
)
|
|
||||||
|
|
||||||
socket_sendererer = app.socket_sendererer()
|
|
||||||
if (
|
|
||||||
copilot.animation1threshold
|
|
||||||
and int(g.data["amount"]) > copilot.animation1threshold
|
|
||||||
):
|
|
||||||
data = copilot.animation1
|
|
||||||
if (
|
|
||||||
copilot.animation2threshold
|
|
||||||
and int(g.data["amount"]) > copilot.animation2threshold
|
|
||||||
):
|
|
||||||
data = copilot.animation2
|
|
||||||
if (
|
|
||||||
copilot.animation3threshold
|
|
||||||
and int(g.data["amount"]) > copilot.animation3threshold
|
|
||||||
):
|
|
||||||
data = copilot.animation3
|
|
||||||
async with socket_sendererer.websocket(
|
|
||||||
"/ws/compose/" + copilot_id
|
|
||||||
) as the_websocket:
|
|
||||||
await the_websocket.send(data)
|
|
||||||
|
|
||||||
return "", HTTPStatus.OK
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue