mirror of
https://github.com/lnbits/lnbits.git
synced 2025-06-07 05:33:06 +02:00
fix mypy for extensions (#873)
* explicitly exclude all extensions from mypy * fix example extension mypy * fix subdomains extension mypy + 1 type error fixed * fix mypy discordbot * mypy check copilot extensnion * copilot black * add invoices ext to ignore * add boltz and boltcard * copilit id is necessary * was discordbot is ok Co-authored-by: dni <dni.khr@gmail.com>
This commit is contained in:
parent
09cf654427
commit
09871bbabc
@ -10,7 +10,7 @@ from .models import Copilots, CreateCopilotData
|
|||||||
|
|
||||||
async def create_copilot(
|
async def create_copilot(
|
||||||
data: CreateCopilotData, inkey: Optional[str] = ""
|
data: CreateCopilotData, inkey: Optional[str] = ""
|
||||||
) -> Copilots:
|
) -> Optional[Copilots]:
|
||||||
copilot_id = urlsafe_short_hash()
|
copilot_id = urlsafe_short_hash()
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
@ -67,19 +67,19 @@ async def create_copilot(
|
|||||||
|
|
||||||
|
|
||||||
async def update_copilot(
|
async def update_copilot(
|
||||||
data: CreateCopilotData, copilot_id: Optional[str] = ""
|
data: CreateCopilotData, copilot_id: str
|
||||||
) -> Optional[Copilots]:
|
) -> Optional[Copilots]:
|
||||||
q = ", ".join([f"{field[0]} = ?" for field in data])
|
q = ", ".join([f"{field[0]} = ?" for field in data])
|
||||||
items = [f"{field[1]}" for field in data]
|
items = [f"{field[1]}" for field in data]
|
||||||
items.append(copilot_id)
|
items.append(copilot_id)
|
||||||
await db.execute(f"UPDATE copilot.newer_copilots SET {q} WHERE id = ?", (items))
|
await db.execute(f"UPDATE copilot.newer_copilots SET {q} WHERE id = ?", (items,))
|
||||||
row = await db.fetchone(
|
row = await db.fetchone(
|
||||||
"SELECT * FROM copilot.newer_copilots WHERE id = ?", (copilot_id,)
|
"SELECT * FROM copilot.newer_copilots WHERE id = ?", (copilot_id,)
|
||||||
)
|
)
|
||||||
return Copilots(**row) if row else None
|
return Copilots(**row) if row else None
|
||||||
|
|
||||||
|
|
||||||
async def get_copilot(copilot_id: str) -> Copilots:
|
async def get_copilot(copilot_id: str) -> Optional[Copilots]:
|
||||||
row = await db.fetchone(
|
row = await db.fetchone(
|
||||||
"SELECT * FROM copilot.newer_copilots WHERE id = ?", (copilot_id,)
|
"SELECT * FROM copilot.newer_copilots WHERE id = ?", (copilot_id,)
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ async def wait_for_paid_invoices():
|
|||||||
async def on_invoice_paid(payment: Payment) -> None:
|
async def on_invoice_paid(payment: Payment) -> None:
|
||||||
webhook = None
|
webhook = None
|
||||||
data = None
|
data = None
|
||||||
if payment.extra.get("tag") != "copilot":
|
if not payment.extra or payment.extra.get("tag") != "copilot":
|
||||||
# not an copilot invoice
|
# not an copilot invoice
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -71,12 +71,12 @@ async def on_invoice_paid(payment: Payment) -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def mark_webhook_sent(payment: Payment, status: int) -> None:
|
async def mark_webhook_sent(payment: Payment, status: int) -> None:
|
||||||
payment.extra["wh_status"] = status
|
if payment.extra:
|
||||||
|
payment.extra["wh_status"] = status
|
||||||
await core_db.execute(
|
await core_db.execute(
|
||||||
"""
|
"""
|
||||||
UPDATE apipayments SET extra = ?
|
UPDATE apipayments SET extra = ?
|
||||||
WHERE hash = ?
|
WHERE hash = ?
|
||||||
""",
|
""",
|
||||||
(json.dumps(payment.extra), payment.payment_hash),
|
(json.dumps(payment.extra), payment.payment_hash),
|
||||||
)
|
)
|
||||||
|
@ -15,7 +15,9 @@ templates = Jinja2Templates(directory="templates")
|
|||||||
|
|
||||||
|
|
||||||
@copilot_ext.get("/", response_class=HTMLResponse)
|
@copilot_ext.get("/", response_class=HTMLResponse)
|
||||||
async def index(request: Request, user: User = Depends(check_user_exists)):
|
async def index(
|
||||||
|
request: Request, user: User = Depends(check_user_exists) # type: ignore
|
||||||
|
):
|
||||||
return copilot_renderer().TemplateResponse(
|
return copilot_renderer().TemplateResponse(
|
||||||
"copilot/index.html", {"request": request, "user": user.dict()}
|
"copilot/index.html", {"request": request, "user": user.dict()}
|
||||||
)
|
)
|
||||||
@ -44,7 +46,7 @@ class ConnectionManager:
|
|||||||
|
|
||||||
async def connect(self, websocket: WebSocket, copilot_id: str):
|
async def connect(self, websocket: WebSocket, copilot_id: str):
|
||||||
await websocket.accept()
|
await websocket.accept()
|
||||||
websocket.id = copilot_id
|
websocket.id = copilot_id # type: ignore
|
||||||
self.active_connections.append(websocket)
|
self.active_connections.append(websocket)
|
||||||
|
|
||||||
def disconnect(self, websocket: WebSocket):
|
def disconnect(self, websocket: WebSocket):
|
||||||
@ -52,7 +54,7 @@ class ConnectionManager:
|
|||||||
|
|
||||||
async def send_personal_message(self, message: str, copilot_id: str):
|
async def send_personal_message(self, message: str, copilot_id: str):
|
||||||
for connection in self.active_connections:
|
for connection in self.active_connections:
|
||||||
if connection.id == copilot_id:
|
if connection.id == copilot_id: # type: ignore
|
||||||
await connection.send_text(message)
|
await connection.send_text(message)
|
||||||
|
|
||||||
async def broadcast(self, message: str):
|
async def broadcast(self, message: str):
|
||||||
|
@ -23,7 +23,7 @@ from .views import updater
|
|||||||
|
|
||||||
@copilot_ext.get("/api/v1/copilot")
|
@copilot_ext.get("/api/v1/copilot")
|
||||||
async def api_copilots_retrieve(
|
async def api_copilots_retrieve(
|
||||||
req: Request, wallet: WalletTypeInfo = Depends(get_key_type)
|
req: Request, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
):
|
):
|
||||||
wallet_user = wallet.wallet.user
|
wallet_user = wallet.wallet.user
|
||||||
copilots = [copilot.dict() for copilot in await get_copilots(wallet_user)]
|
copilots = [copilot.dict() for copilot in await get_copilots(wallet_user)]
|
||||||
@ -37,7 +37,7 @@ async def api_copilots_retrieve(
|
|||||||
async def api_copilot_retrieve(
|
async def api_copilot_retrieve(
|
||||||
req: Request,
|
req: Request,
|
||||||
copilot_id: str = Query(None),
|
copilot_id: str = Query(None),
|
||||||
wallet: WalletTypeInfo = Depends(get_key_type),
|
wallet: WalletTypeInfo = Depends(get_key_type), # type: ignore
|
||||||
):
|
):
|
||||||
copilot = await get_copilot(copilot_id)
|
copilot = await get_copilot(copilot_id)
|
||||||
if not copilot:
|
if not copilot:
|
||||||
@ -54,7 +54,7 @@ async def api_copilot_retrieve(
|
|||||||
async def api_copilot_create_or_update(
|
async def api_copilot_create_or_update(
|
||||||
data: CreateCopilotData,
|
data: CreateCopilotData,
|
||||||
copilot_id: str = Query(None),
|
copilot_id: str = Query(None),
|
||||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
wallet: WalletTypeInfo = Depends(require_admin_key), # type: ignore
|
||||||
):
|
):
|
||||||
data.user = wallet.wallet.user
|
data.user = wallet.wallet.user
|
||||||
data.wallet = wallet.wallet.id
|
data.wallet = wallet.wallet.id
|
||||||
@ -67,7 +67,8 @@ async def api_copilot_create_or_update(
|
|||||||
|
|
||||||
@copilot_ext.delete("/api/v1/copilot/{copilot_id}")
|
@copilot_ext.delete("/api/v1/copilot/{copilot_id}")
|
||||||
async def api_copilot_delete(
|
async def api_copilot_delete(
|
||||||
copilot_id: str = Query(None), wallet: WalletTypeInfo = Depends(require_admin_key)
|
copilot_id: str = Query(None),
|
||||||
|
wallet: WalletTypeInfo = Depends(require_admin_key), # type: ignore
|
||||||
):
|
):
|
||||||
copilot = await get_copilot(copilot_id)
|
copilot = await get_copilot(copilot_id)
|
||||||
|
|
||||||
|
@ -98,21 +98,21 @@ async def get_discordbot_wallet(wallet_id: str) -> Optional[Wallets]:
|
|||||||
return Wallets(**row) if row else None
|
return Wallets(**row) if row else None
|
||||||
|
|
||||||
|
|
||||||
async def get_discordbot_wallets(admin_id: str) -> Optional[Wallets]:
|
async def get_discordbot_wallets(admin_id: str) -> List[Wallets]:
|
||||||
rows = await db.fetchall(
|
rows = await db.fetchall(
|
||||||
"SELECT * FROM discordbot.wallets WHERE admin = ?", (admin_id,)
|
"SELECT * FROM discordbot.wallets WHERE admin = ?", (admin_id,)
|
||||||
)
|
)
|
||||||
return [Wallets(**row) for row in rows]
|
return [Wallets(**row) for row in rows]
|
||||||
|
|
||||||
|
|
||||||
async def get_discordbot_users_wallets(user_id: str) -> Optional[Wallets]:
|
async def get_discordbot_users_wallets(user_id: str) -> List[Wallets]:
|
||||||
rows = await db.fetchall(
|
rows = await db.fetchall(
|
||||||
"""SELECT * FROM discordbot.wallets WHERE "user" = ?""", (user_id,)
|
"""SELECT * FROM discordbot.wallets WHERE "user" = ?""", (user_id,)
|
||||||
)
|
)
|
||||||
return [Wallets(**row) for row in rows]
|
return [Wallets(**row) for row in rows]
|
||||||
|
|
||||||
|
|
||||||
async def get_discordbot_wallet_transactions(wallet_id: str) -> Optional[Payment]:
|
async def get_discordbot_wallet_transactions(wallet_id: str) -> List[Payment]:
|
||||||
return await get_payments(
|
return await get_payments(
|
||||||
wallet_id=wallet_id, complete=True, pending=False, outgoing=True, incoming=True
|
wallet_id=wallet_id, complete=True, pending=False, outgoing=True, incoming=True
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,9 @@ from . import discordbot_ext, discordbot_renderer
|
|||||||
|
|
||||||
|
|
||||||
@discordbot_ext.get("/", response_class=HTMLResponse)
|
@discordbot_ext.get("/", response_class=HTMLResponse)
|
||||||
async def index(request: Request, user: User = Depends(check_user_exists)):
|
async def index(
|
||||||
|
request: Request, user: User = Depends(check_user_exists) # type: ignore
|
||||||
|
):
|
||||||
return discordbot_renderer().TemplateResponse(
|
return discordbot_renderer().TemplateResponse(
|
||||||
"discordbot/index.html", {"request": request, "user": user.dict()}
|
"discordbot/index.html", {"request": request, "user": user.dict()}
|
||||||
)
|
)
|
||||||
|
@ -27,32 +27,37 @@ from .models import CreateUserData, CreateUserWallet
|
|||||||
|
|
||||||
|
|
||||||
@discordbot_ext.get("/api/v1/users", status_code=HTTPStatus.OK)
|
@discordbot_ext.get("/api/v1/users", status_code=HTTPStatus.OK)
|
||||||
async def api_discordbot_users(wallet: WalletTypeInfo = Depends(get_key_type)):
|
async def api_discordbot_users(
|
||||||
|
wallet: WalletTypeInfo = Depends(get_key_type), # type: ignore
|
||||||
|
):
|
||||||
user_id = wallet.wallet.user
|
user_id = wallet.wallet.user
|
||||||
return [user.dict() for user in await get_discordbot_users(user_id)]
|
return [user.dict() for user in await get_discordbot_users(user_id)]
|
||||||
|
|
||||||
|
|
||||||
@discordbot_ext.get("/api/v1/users/{user_id}", status_code=HTTPStatus.OK)
|
@discordbot_ext.get("/api/v1/users/{user_id}", status_code=HTTPStatus.OK)
|
||||||
async def api_discordbot_user(user_id, wallet: WalletTypeInfo = Depends(get_key_type)):
|
async def api_discordbot_user(
|
||||||
|
user_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
|
):
|
||||||
user = await get_discordbot_user(user_id)
|
user = await get_discordbot_user(user_id)
|
||||||
return user.dict()
|
if user:
|
||||||
|
return user.dict()
|
||||||
|
|
||||||
|
|
||||||
@discordbot_ext.post("/api/v1/users", status_code=HTTPStatus.CREATED)
|
@discordbot_ext.post("/api/v1/users", status_code=HTTPStatus.CREATED)
|
||||||
async def api_discordbot_users_create(
|
async def api_discordbot_users_create(
|
||||||
data: CreateUserData, wallet: WalletTypeInfo = Depends(get_key_type)
|
data: CreateUserData, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
):
|
):
|
||||||
user = await create_discordbot_user(data)
|
user = await create_discordbot_user(data)
|
||||||
full = user.dict()
|
full = user.dict()
|
||||||
full["wallets"] = [
|
wallets = await get_discordbot_users_wallets(user.id)
|
||||||
wallet.dict() for wallet in await get_discordbot_users_wallets(user.id)
|
if wallets:
|
||||||
]
|
full["wallets"] = [wallet for wallet in wallets]
|
||||||
return full
|
return full
|
||||||
|
|
||||||
|
|
||||||
@discordbot_ext.delete("/api/v1/users/{user_id}")
|
@discordbot_ext.delete("/api/v1/users/{user_id}")
|
||||||
async def api_discordbot_users_delete(
|
async def api_discordbot_users_delete(
|
||||||
user_id, wallet: WalletTypeInfo = Depends(get_key_type)
|
user_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
):
|
):
|
||||||
user = await get_discordbot_user(user_id)
|
user = await get_discordbot_user(user_id)
|
||||||
if not user:
|
if not user:
|
||||||
@ -75,7 +80,7 @@ async def api_discordbot_activate_extension(
|
|||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="User does not exist."
|
status_code=HTTPStatus.NOT_FOUND, detail="User does not exist."
|
||||||
)
|
)
|
||||||
update_user_extension(user_id=userid, extension=extension, active=active)
|
await update_user_extension(user_id=userid, extension=extension, active=active)
|
||||||
return {"extension": "updated"}
|
return {"extension": "updated"}
|
||||||
|
|
||||||
|
|
||||||
@ -84,7 +89,7 @@ async def api_discordbot_activate_extension(
|
|||||||
|
|
||||||
@discordbot_ext.post("/api/v1/wallets")
|
@discordbot_ext.post("/api/v1/wallets")
|
||||||
async def api_discordbot_wallets_create(
|
async def api_discordbot_wallets_create(
|
||||||
data: CreateUserWallet, wallet: WalletTypeInfo = Depends(get_key_type)
|
data: CreateUserWallet, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
):
|
):
|
||||||
user = await create_discordbot_wallet(
|
user = await create_discordbot_wallet(
|
||||||
user_id=data.user_id, wallet_name=data.wallet_name, admin_id=data.admin_id
|
user_id=data.user_id, wallet_name=data.wallet_name, admin_id=data.admin_id
|
||||||
@ -93,28 +98,30 @@ async def api_discordbot_wallets_create(
|
|||||||
|
|
||||||
|
|
||||||
@discordbot_ext.get("/api/v1/wallets")
|
@discordbot_ext.get("/api/v1/wallets")
|
||||||
async def api_discordbot_wallets(wallet: WalletTypeInfo = Depends(get_key_type)):
|
async def api_discordbot_wallets(
|
||||||
|
wallet: WalletTypeInfo = Depends(get_key_type), # type: ignore
|
||||||
|
):
|
||||||
admin_id = wallet.wallet.user
|
admin_id = wallet.wallet.user
|
||||||
return [wallet.dict() for wallet in await get_discordbot_wallets(admin_id)]
|
return await get_discordbot_wallets(admin_id)
|
||||||
|
|
||||||
|
|
||||||
@discordbot_ext.get("/api/v1/transactions/{wallet_id}")
|
@discordbot_ext.get("/api/v1/transactions/{wallet_id}")
|
||||||
async def api_discordbot_wallet_transactions(
|
async def api_discordbot_wallet_transactions(
|
||||||
wallet_id, wallet: WalletTypeInfo = Depends(get_key_type)
|
wallet_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
):
|
):
|
||||||
return await get_discordbot_wallet_transactions(wallet_id)
|
return await get_discordbot_wallet_transactions(wallet_id)
|
||||||
|
|
||||||
|
|
||||||
@discordbot_ext.get("/api/v1/wallets/{user_id}")
|
@discordbot_ext.get("/api/v1/wallets/{user_id}")
|
||||||
async def api_discordbot_users_wallets(
|
async def api_discordbot_users_wallets(
|
||||||
user_id, wallet: WalletTypeInfo = Depends(get_key_type)
|
user_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
):
|
):
|
||||||
return [s_wallet.dict() for s_wallet in await get_discordbot_users_wallets(user_id)]
|
return await get_discordbot_users_wallets(user_id)
|
||||||
|
|
||||||
|
|
||||||
@discordbot_ext.delete("/api/v1/wallets/{wallet_id}")
|
@discordbot_ext.delete("/api/v1/wallets/{wallet_id}")
|
||||||
async def api_discordbot_wallets_delete(
|
async def api_discordbot_wallets_delete(
|
||||||
wallet_id, wallet: WalletTypeInfo = Depends(get_key_type)
|
wallet_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
):
|
):
|
||||||
get_wallet = await get_discordbot_wallet(wallet_id)
|
get_wallet = await get_discordbot_wallet(wallet_id)
|
||||||
if not get_wallet:
|
if not get_wallet:
|
||||||
|
@ -12,7 +12,10 @@ templates = Jinja2Templates(directory="templates")
|
|||||||
|
|
||||||
|
|
||||||
@example_ext.get("/", response_class=HTMLResponse)
|
@example_ext.get("/", response_class=HTMLResponse)
|
||||||
async def index(request: Request, user: User = Depends(check_user_exists)):
|
async def index(
|
||||||
|
request: Request,
|
||||||
|
user: User = Depends(check_user_exists), # type: ignore
|
||||||
|
):
|
||||||
return example_renderer().TemplateResponse(
|
return example_renderer().TemplateResponse(
|
||||||
"example/index.html", {"request": request, "user": user.dict()}
|
"example/index.html", {"request": request, "user": user.dict()}
|
||||||
)
|
)
|
||||||
|
@ -3,10 +3,10 @@ from typing import List, Optional, Union
|
|||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
|
|
||||||
from . import db
|
from . import db
|
||||||
from .models import CreateDomain, Domains, Subdomains
|
from .models import CreateDomain, CreateSubdomain, Domains, Subdomains
|
||||||
|
|
||||||
|
|
||||||
async def create_subdomain(payment_hash, wallet, data: CreateDomain) -> Subdomains:
|
async def create_subdomain(payment_hash, wallet, data: CreateSubdomain) -> Subdomains:
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO subdomains.subdomain (id, domain, email, subdomain, ip, wallet, sats, duration, paid, record_type)
|
INSERT INTO subdomains.subdomain (id, domain, email, subdomain, ip, wallet, sats, duration, paid, record_type)
|
||||||
|
@ -3,24 +3,24 @@ from pydantic.main import BaseModel
|
|||||||
|
|
||||||
|
|
||||||
class CreateDomain(BaseModel):
|
class CreateDomain(BaseModel):
|
||||||
wallet: str = Query(...)
|
wallet: str = Query(...) # type: ignore
|
||||||
domain: str = Query(...)
|
domain: str = Query(...) # type: ignore
|
||||||
cf_token: str = Query(...)
|
cf_token: str = Query(...) # type: ignore
|
||||||
cf_zone_id: str = Query(...)
|
cf_zone_id: str = Query(...) # type: ignore
|
||||||
webhook: str = Query("")
|
webhook: str = Query("") # type: ignore
|
||||||
description: str = Query(..., min_length=0)
|
description: str = Query(..., min_length=0) # type: ignore
|
||||||
cost: int = Query(..., ge=0)
|
cost: int = Query(..., ge=0) # type: ignore
|
||||||
allowed_record_types: str = Query(...)
|
allowed_record_types: str = Query(...) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class CreateSubdomain(BaseModel):
|
class CreateSubdomain(BaseModel):
|
||||||
domain: str = Query(...)
|
domain: str = Query(...) # type: ignore
|
||||||
subdomain: str = Query(...)
|
subdomain: str = Query(...) # type: ignore
|
||||||
email: str = Query(...)
|
email: str = Query(...) # type: ignore
|
||||||
ip: str = Query(...)
|
ip: str = Query(...) # type: ignore
|
||||||
sats: int = Query(..., ge=0)
|
sats: int = Query(..., ge=0) # type: ignore
|
||||||
duration: int = Query(...)
|
duration: int = Query(...) # type: ignore
|
||||||
record_type: str = Query(...)
|
record_type: str = Query(...) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class Domains(BaseModel):
|
class Domains(BaseModel):
|
||||||
|
@ -20,7 +20,7 @@ async def wait_for_paid_invoices():
|
|||||||
|
|
||||||
|
|
||||||
async def on_invoice_paid(payment: Payment) -> None:
|
async def on_invoice_paid(payment: Payment) -> None:
|
||||||
if payment.extra.get("tag") != "lnsubdomain":
|
if not payment.extra or payment.extra.get("tag") != "lnsubdomain":
|
||||||
# not an lnurlp invoice
|
# not an lnurlp invoice
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ async def on_invoice_paid(payment: Payment) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
### Use webhook to notify about cloudflare registration
|
### Use webhook to notify about cloudflare registration
|
||||||
if domain.webhook:
|
if domain and domain.webhook:
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
try:
|
try:
|
||||||
r = await client.post(
|
r = await client.post(
|
||||||
|
@ -16,7 +16,9 @@ templates = Jinja2Templates(directory="templates")
|
|||||||
|
|
||||||
|
|
||||||
@subdomains_ext.get("/", response_class=HTMLResponse)
|
@subdomains_ext.get("/", response_class=HTMLResponse)
|
||||||
async def index(request: Request, user: User = Depends(check_user_exists)):
|
async def index(
|
||||||
|
request: Request, user: User = Depends(check_user_exists) # type:ignore
|
||||||
|
):
|
||||||
return subdomains_renderer().TemplateResponse(
|
return subdomains_renderer().TemplateResponse(
|
||||||
"subdomains/index.html", {"request": request, "user": user.dict()}
|
"subdomains/index.html", {"request": request, "user": user.dict()}
|
||||||
)
|
)
|
||||||
|
@ -29,12 +29,15 @@ from .crud import (
|
|||||||
|
|
||||||
@subdomains_ext.get("/api/v1/domains")
|
@subdomains_ext.get("/api/v1/domains")
|
||||||
async def api_domains(
|
async def api_domains(
|
||||||
g: WalletTypeInfo = Depends(get_key_type), all_wallets: bool = Query(False)
|
g: WalletTypeInfo = Depends(get_key_type), # type: ignore
|
||||||
|
all_wallets: bool = Query(False),
|
||||||
):
|
):
|
||||||
wallet_ids = [g.wallet.id]
|
wallet_ids = [g.wallet.id]
|
||||||
|
|
||||||
if all_wallets:
|
if all_wallets:
|
||||||
wallet_ids = (await get_user(g.wallet.user)).wallet_ids
|
user = await get_user(g.wallet.user)
|
||||||
|
if user is not None:
|
||||||
|
wallet_ids = user.wallet_ids
|
||||||
|
|
||||||
return [domain.dict() for domain in await get_domains(wallet_ids)]
|
return [domain.dict() for domain in await get_domains(wallet_ids)]
|
||||||
|
|
||||||
@ -42,7 +45,9 @@ async def api_domains(
|
|||||||
@subdomains_ext.post("/api/v1/domains")
|
@subdomains_ext.post("/api/v1/domains")
|
||||||
@subdomains_ext.put("/api/v1/domains/{domain_id}")
|
@subdomains_ext.put("/api/v1/domains/{domain_id}")
|
||||||
async def api_domain_create(
|
async def api_domain_create(
|
||||||
data: CreateDomain, domain_id=None, g: WalletTypeInfo = Depends(get_key_type)
|
data: CreateDomain,
|
||||||
|
domain_id=None,
|
||||||
|
g: WalletTypeInfo = Depends(get_key_type), # type: ignore
|
||||||
):
|
):
|
||||||
if domain_id:
|
if domain_id:
|
||||||
domain = await get_domain(domain_id)
|
domain = await get_domain(domain_id)
|
||||||
@ -63,7 +68,9 @@ async def api_domain_create(
|
|||||||
|
|
||||||
|
|
||||||
@subdomains_ext.delete("/api/v1/domains/{domain_id}")
|
@subdomains_ext.delete("/api/v1/domains/{domain_id}")
|
||||||
async def api_domain_delete(domain_id, g: WalletTypeInfo = Depends(get_key_type)):
|
async def api_domain_delete(
|
||||||
|
domain_id, g: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
|
):
|
||||||
domain = await get_domain(domain_id)
|
domain = await get_domain(domain_id)
|
||||||
|
|
||||||
if not domain:
|
if not domain:
|
||||||
@ -82,12 +89,14 @@ async def api_domain_delete(domain_id, g: WalletTypeInfo = Depends(get_key_type)
|
|||||||
|
|
||||||
@subdomains_ext.get("/api/v1/subdomains")
|
@subdomains_ext.get("/api/v1/subdomains")
|
||||||
async def api_subdomains(
|
async def api_subdomains(
|
||||||
all_wallets: bool = Query(False), g: WalletTypeInfo = Depends(get_key_type)
|
all_wallets: bool = Query(False), g: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
):
|
):
|
||||||
wallet_ids = [g.wallet.id]
|
wallet_ids = [g.wallet.id]
|
||||||
|
|
||||||
if all_wallets:
|
if all_wallets:
|
||||||
wallet_ids = (await get_user(g.wallet.user)).wallet_ids
|
user = await get_user(g.wallet.user)
|
||||||
|
if user is not None:
|
||||||
|
wallet_ids = user.wallet_ids
|
||||||
|
|
||||||
return [domain.dict() for domain in await get_subdomains(wallet_ids)]
|
return [domain.dict() for domain in await get_subdomains(wallet_ids)]
|
||||||
|
|
||||||
@ -173,7 +182,9 @@ async def api_subdomain_send_subdomain(payment_hash):
|
|||||||
|
|
||||||
|
|
||||||
@subdomains_ext.delete("/api/v1/subdomains/{subdomain_id}")
|
@subdomains_ext.delete("/api/v1/subdomains/{subdomain_id}")
|
||||||
async def api_subdomain_delete(subdomain_id, g: WalletTypeInfo = Depends(get_key_type)):
|
async def api_subdomain_delete(
|
||||||
|
subdomain_id, g: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||||
|
):
|
||||||
subdomain = await get_subdomain(subdomain_id)
|
subdomain = await get_subdomain(subdomain_id)
|
||||||
|
|
||||||
if not subdomain:
|
if not subdomain:
|
||||||
|
@ -89,8 +89,34 @@ profile = "black"
|
|||||||
ignore_missing_imports = "True"
|
ignore_missing_imports = "True"
|
||||||
files = "lnbits"
|
files = "lnbits"
|
||||||
exclude = """(?x)(
|
exclude = """(?x)(
|
||||||
^lnbits/extensions.
|
^lnbits/extensions/bleskomat.
|
||||||
| ^lnbits/wallets/lnd_grpc_files.
|
| ^lnbits/extensions/boltz.
|
||||||
|
| ^lnbits/extensions/boltcards.
|
||||||
|
| ^lnbits/extensions/events.
|
||||||
|
| ^lnbits/extensions/hivemind.
|
||||||
|
| ^lnbits/extensions/invoices.
|
||||||
|
| ^lnbits/extensions/jukebox.
|
||||||
|
| ^lnbits/extensions/livestream.
|
||||||
|
| ^lnbits/extensions/lnaddress.
|
||||||
|
| ^lnbits/extensions/lndhub.
|
||||||
|
| ^lnbits/extensions/lnticket.
|
||||||
|
| ^lnbits/extensions/lnurldevice.
|
||||||
|
| ^lnbits/extensions/lnurlp.
|
||||||
|
| ^lnbits/extensions/lnurlpayout.
|
||||||
|
| ^lnbits/extensions/ngrok.
|
||||||
|
| ^lnbits/extensions/offlineshop.
|
||||||
|
| ^lnbits/extensions/paywall.
|
||||||
|
| ^lnbits/extensions/satsdice.
|
||||||
|
| ^lnbits/extensions/satspay.
|
||||||
|
| ^lnbits/extensions/scrub.
|
||||||
|
| ^lnbits/extensions/splitpayments.
|
||||||
|
| ^lnbits/extensions/streamalerts.
|
||||||
|
| ^lnbits/extensions/tipjar.
|
||||||
|
| ^lnbits/extensions/tpos.
|
||||||
|
| ^lnbits/extensions/usermanager.
|
||||||
|
| ^lnbits/extensions/watchonly.
|
||||||
|
| ^lnbits/extensions/withdraw.
|
||||||
|
| ^lnbits/wallets/lnd_grpc_files.
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user