diff --git a/config.json b/config.json
index 8545e6d..d32307c 100644
--- a/config.json
+++ b/config.json
@@ -3,7 +3,7 @@
"version": "1.1.0",
"short_description": "Video tips/animations/webhooks",
"tile": "/copilot/static/bitcoin-streaming.png",
- "min_lnbits_version": "1.7.0-rc1",
+ "min_lnbits_version": "1.7.0",
"contributors": [
{
"name": "Ben Arc",
diff --git a/static/js/index.js b/static/js/index.js
index 4980e32..c0a0cb6 100644
--- a/static/js/index.js
+++ b/static/js/index.js
@@ -161,13 +161,13 @@ window.app = Vue.createApp({
this.getCopilot(copilot_id)
let params =
'scrollbars=no, resizable=no,status=no,location=no,toolbar=no,menubar=no,width=1200,height=644,left=410,top=100'
- open('../copilot/cp/', '_blank', params)
+ open('/copilot/cp', '_blank', params)
},
openCopilotPanel(copilot_id) {
this.getCopilot(copilot_id)
let params =
'scrollbars=no, resizable=no,status=no,location=no,toolbar=no,menubar=no,width=300,height=450,left=10,top=400'
- open('../copilot/pn/', '_blank', params)
+ open('/copilot/pn', '_blank', params)
},
deleteCopilotLink(copilotId) {
const link = _.findWhere(this.copilotLinks, {id: copilotId})
diff --git a/tasks.py b/tasks.py
index 1edaea1..473cb55 100644
--- a/tasks.py
+++ b/tasks.py
@@ -6,6 +6,7 @@
from lnbits.core.services import websocket_updater
from lnbits.helpers import get_current_extension_name
from lnbits.tasks import register_invoice_listener
+from lnbits.utils.safe_http import SafeHttpClient
from loguru import logger
from .crud import get_copilot
@@ -46,7 +47,7 @@ async def on_invoice_paid(payment: Payment) -> None:
data = copilot.animation3
webhook = copilot.animation1webhook
if webhook:
- async with httpx.AsyncClient() as client:
+ async with SafeHttpClient(read_body=False) as client:
try:
r = await client.post(
webhook,
@@ -60,7 +61,7 @@ async def on_invoice_paid(payment: Payment) -> None:
)
r.raise_for_status()
payment.extra["wh_status"] = r.status_code
- except (httpx.ConnectError, httpx.RequestError):
+ except (httpx.HTTPError, httpx.InvalidURL, ValueError):
payment.extra["wh_status"] = -1
finally:
await update_payment(payment)
diff --git a/templates/copilot/compose.html b/templates/copilot/compose.html
index 9f00304..3048e80 100644
--- a/templates/copilot/compose.html
+++ b/templates/copilot/compose.html
@@ -8,6 +8,10 @@
@@ -23,6 +27,7 @@
{
+ if (!video.isConnected) {
+ stream.getTracks().forEach(track => track.stop())
+ return
+ }
video.srcObject = stream
})
.catch(LNbits.utils.notifyApiError)
}
},
+ stopCamera(video) {
+ video.srcObject?.getTracks().forEach(track => track.stop())
+ video.srcObject = null
+ },
initScreenShare() {
const video = document.querySelector('#videoScreen')
navigator.mediaDevices
@@ -251,8 +263,9 @@
pushAnim(content) {
document.getElementById('animations').style.width = content[0]
document.getElementById('animations').src = content[1]
- if (content[2] != 'none') {
- this.showNotif(content[2])
+ const comment = (content[2] || '').trim()
+ if (comment && comment !== 'none') {
+ this.showNotif(comment)
}
setTimeout(() => {
document.getElementById('animations').src = ''
@@ -299,9 +312,6 @@
.catch(LNbits.utils.notifyApiError)
}
},
- mounted() {
- this.initCamera()
- },
created() {
$(() => {
$('#draggableqr').draggable()
@@ -361,7 +371,8 @@
this.connection = new WebSocket(localUrl)
this.connection.onmessage = e => {
console.log(e)
- res = e.data.replace(' ', '').split('-')
+ const [event, ...commentParts] = e.data.split('-')
+ const res = [event.trim(), commentParts.join('-').trim()]
if (res[0] == 'rocket') {
addTask(['40%', '/copilot/static/rocket.gif', res[1]])
}
diff --git a/templates/copilot/panel.html b/templates/copilot/panel.html
index 7821da9..bbad38d 100644
--- a/templates/copilot/panel.html
+++ b/templates/copilot/panel.html
@@ -131,7 +131,7 @@
openCompose() {
let params =
'scrollbars=no, resizable=no,status=no,location=no,toolbar=no,menubar=no,width=1200,height=644,left=410,top=100'
- open('../cp/', 'test', params)
+ open('/copilot/cp', 'test', params)
},
animationBTN(name) {
LNbits.api
diff --git a/views.py b/views.py
index 783207e..fe52fd0 100644
--- a/views.py
+++ b/views.py
@@ -24,14 +24,14 @@ async def index(request: Request, user: User = Depends(check_user_exists)):
)
-@copilot_generic_router.get("/cp/", response_class=HTMLResponse)
+@copilot_generic_router.get("/cp", response_class=HTMLResponse)
async def compose(request: Request):
return copilot_renderer().TemplateResponse(
"copilot/compose.html", {"request": request}
)
-@copilot_generic_router.get("/pn/", response_class=HTMLResponse)
+@copilot_generic_router.get("/pn", response_class=HTMLResponse)
async def panel(request: Request):
return copilot_renderer().TemplateResponse(
"copilot/panel.html", {"request": request}
diff --git a/views_lnurl.py b/views_lnurl.py
index 365eb2d..035c9fd 100644
--- a/views_lnurl.py
+++ b/views_lnurl.py
@@ -13,7 +13,10 @@
@copilot_lnurl_router.get(
- "/lnurl/{cp_id}", response_class=HTMLResponse, name="copilot.lnurl_response"
+ "/lnurl/{cp_id}",
+ response_class=HTMLResponse,
+ name="copilot.lnurl_response",
+ openapi_extra={"x-lnbits-local-lnurl": True},
)
async def lnurl_response(req: Request, cp_id: str):
cp = await get_copilot(cp_id)
@@ -35,7 +38,11 @@ async def lnurl_response(req: Request, cp_id: str):
return json.dumps(pay_response)
-@copilot_lnurl_router.get("/lnurl/cb/{cp_id}", name="copilot.lnurl_callback")
+@copilot_lnurl_router.get(
+ "/lnurl/cb/{cp_id}",
+ name="copilot.lnurl_callback",
+ openapi_extra={"x-lnbits-local-lnurl": True},
+)
async def lnurl_callback(
cp_id: str, amount: str = Query(None), comment: str = Query(None)
):