I want them to turn black

This commit is contained in:
benarc
2021-10-17 18:33:29 +01:00
parent 70facdaa93
commit 1d3bb016a2
84 changed files with 899 additions and 1008 deletions
+1 -5
View File
@@ -19,11 +19,7 @@ copilot_ext: APIRouter = APIRouter(prefix="/copilot", tags=["copilot"])
def copilot_renderer():
return template_renderer(
[
"lnbits/extensions/copilot/templates",
]
)
return template_renderer(["lnbits/extensions/copilot/templates"])
from .views_api import * # noqa
+8 -9
View File
@@ -8,7 +8,11 @@ from http import HTTPStatus
from starlette.exceptions import HTTPException
from starlette.responses import HTMLResponse, JSONResponse # type: ignore
import base64
from lnurl import LnurlPayResponse, LnurlPayActionResponse, LnurlErrorResponse # type: ignore
from lnurl import (
LnurlPayResponse,
LnurlPayActionResponse,
LnurlErrorResponse,
) # type: ignore
from lnurl.types import LnurlPayMetadata
from lnbits.core.services import create_invoice
from .models import Copilots, CreateCopilotData
@@ -24,8 +28,7 @@ async def lnurl_response(req: Request, cp_id: str = Query(None)):
cp = await get_copilot(cp_id)
if not cp:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="Copilot not found",
status_code=HTTPStatus.NOT_FOUND, detail="Copilot not found"
)
resp = LnurlPayResponse(
@@ -49,8 +52,7 @@ async def lnurl_callback(
cp = await get_copilot(cp_id)
if not cp:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="Copilot not found",
status_code=HTTPStatus.NOT_FOUND, detail="Copilot not found"
)
amount_received = int(amount)
@@ -84,9 +86,6 @@ async def lnurl_callback(
extra={"tag": "copilot", "copilot": cp.id, "comment": comment},
)
resp = LnurlPayActionResponse(
pr=payment_request,
success_action=None,
disposable=False,
routes=[],
pr=payment_request, success_action=None, disposable=False, routes=[]
)
return resp.dict()
+1 -2
View File
@@ -38,8 +38,7 @@ async def on_invoice_paid(payment: Payment) -> None:
if not copilot:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="Copilot does not exist",
status_code=HTTPStatus.NOT_FOUND, detail="Copilot does not exist"
)
if copilot.animation1threshold:
if int(payment.amount / 1000) >= copilot.animation1threshold:
+7 -19
View File
@@ -44,10 +44,7 @@ async def api_copilots_retrieve(
try:
return copilots
except:
raise HTTPException(
status_code=HTTPStatus.NO_CONTENT,
detail="No copilots",
)
raise HTTPException(status_code=HTTPStatus.NO_CONTENT, detail="No copilots")
@copilot_ext.get("/api/v1/copilot/{copilot_id}")
@@ -57,8 +54,7 @@ async def api_copilot_retrieve(
copilot = await get_copilot(copilot_id)
if not copilot:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="Copilot not found",
status_code=HTTPStatus.NOT_FOUND, detail="Copilot not found"
)
if not copilot.lnurl_toggle:
return copilot.dict()
@@ -83,15 +79,13 @@ async def api_copilot_create_or_update(
@copilot_ext.delete("/api/v1/copilot/{copilot_id}")
async def api_copilot_delete(
copilot_id: str = Query(None),
wallet: WalletTypeInfo = Depends(get_key_type),
copilot_id: str = Query(None), wallet: WalletTypeInfo = Depends(get_key_type)
):
copilot = await get_copilot(copilot_id)
if not copilot:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="Copilot does not exist",
status_code=HTTPStatus.NOT_FOUND, detail="Copilot does not exist"
)
await delete_copilot(copilot_id)
@@ -101,22 +95,16 @@ async def api_copilot_delete(
@copilot_ext.get("/api/v1/copilot/ws/{copilot_id}/{comment}/{data}")
async def api_copilot_ws_relay(
copilot_id: str = Query(None),
comment: str = Query(None),
data: str = Query(None),
copilot_id: str = Query(None), comment: str = Query(None), data: str = Query(None)
):
copilot = await get_copilot(copilot_id)
print(copilot)
if not copilot:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="Copilot does not exist",
status_code=HTTPStatus.NOT_FOUND, detail="Copilot does not exist"
)
try:
await updater(copilot_id, data, comment)
except:
raise HTTPException(
status_code=HTTPStatus.FORBIDDEN,
detail="Not your copilot",
)
raise HTTPException(status_code=HTTPStatus.FORBIDDEN, detail="Not your copilot")
return ""