+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -393,6 +399,12 @@
label: 'id',
field: 'id'
},
+ {
+ name: 'lnurl_toggle',
+ align: 'left',
+ label: 'Show lnurl pay link',
+ field: 'lnurl_toggle'
+ },
{
name: 'title',
align: 'left',
@@ -417,6 +429,7 @@
formDialogCopilot: {
show: false,
data: {
+ lnurl_toggle: false,
show_message: false,
show_ack: true,
title: ''
diff --git a/lnbits/extensions/copilot/views.py b/lnbits/extensions/copilot/views.py
index 16aba211..31246aa9 100644
--- a/lnbits/extensions/copilot/views.py
+++ b/lnbits/extensions/copilot/views.py
@@ -40,7 +40,9 @@ async def compose(copilot_id):
copilot = await get_copilot(copilot_id) or abort(
HTTPStatus.NOT_FOUND, "Copilot link does not exist."
)
- return await render_template("copilot/compose.html", copilot=copilot, lnurl=copilot.lnurl)
+ if copilot.lnurl_toggle:
+ return await render_template("copilot/compose.html", copilot=copilot, lnurl=copilot.lnurl, lnurl_toggle=copilot.lnurl_toggle)
+ return await render_template("copilot/compose.html", copilot=copilot, lnurl_toggle=copilot.lnurl_toggle)
@copilot_ext.route("/
")
async def panel(copilot_id):
diff --git a/lnbits/extensions/copilot/views_api.py b/lnbits/extensions/copilot/views_api.py
index 959f875c..76e82046 100644
--- a/lnbits/extensions/copilot/views_api.py
+++ b/lnbits/extensions/copilot/views_api.py
@@ -1,5 +1,5 @@
import hashlib
-from quart import g, jsonify, url_for
+from quart import g, jsonify, url_for, websocket
from http import HTTPStatus
import httpx
@@ -26,18 +26,19 @@ from .crud import (
@api_validate_post_request(
schema={
"title": {"type": "string", "empty": False, "required": True},
- "wallet": {"type": "string", "empty": False, "required": True},
+ "lnurl_toggle": {"type": "integer", "empty": False, "required": True},
+ "wallet": {"type": "string", "empty": False, "required": False},
"animation1": {"type": "string", "required": False},
"animation2": {"type": "string", "required": False},
"animation3": {"type": "string", "required": False},
- "animation1threshold": {"type": "string", "required": False},
- "animation2threshold": {"type": "string", "required": False},
- "animation3threshold": {"type": "string", "required": False},
+ "animation1threshold": {"type": "integer", "required": False},
+ "animation2threshold": {"type": "integer", "required": False},
+ "animation3threshold": {"type": "integer", "required": False},
"animation1webhook": {"type": "string", "required": False},
"animation2webhook": {"type": "string", "required": False},
"animation3webhook": {"type": "string", "required": False},
- "lnurl_title": {"type": "string", "empty": False, "required": True},
- "show_message": {"type": "integer", "empty": False, "required": True},
+ "lnurl_title": {"type": "string", "empty": False, "required": False},
+ "show_message": {"type": "integer", "empty": False, "required": False},
"show_ack": {"type": "integer", "empty": False, "required": True},
}
)
@@ -96,4 +97,25 @@ async def api_copilot_delete(copilot_id):
await delete_copilot(copilot_id)
- return "", HTTPStatus.NO_CONTENT
\ No newline at end of file
+ return "", HTTPStatus.NO_CONTENT
+
+#############################PAYMENTHOOK##########################
+
+@copilot_ext.route("/api/v1/copilot/hook/", methods=["POST"])
+async def api_copilot_delete(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 g.data['amount'] > copilot.animation1threshold:
+ data = copilot.animation1
+ if copilot.animation2threshold and g.data['amount'] > copilot.animation2threshold:
+ data = copilot.animation2
+ if copilot.animation3threshold and 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
\ No newline at end of file