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:
@@ -3,10 +3,10 @@ from typing import List, Optional, Union
|
||||
from lnbits.helpers import urlsafe_short_hash
|
||||
|
||||
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(
|
||||
"""
|
||||
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):
|
||||
wallet: str = Query(...)
|
||||
domain: str = Query(...)
|
||||
cf_token: str = Query(...)
|
||||
cf_zone_id: str = Query(...)
|
||||
webhook: str = Query("")
|
||||
description: str = Query(..., min_length=0)
|
||||
cost: int = Query(..., ge=0)
|
||||
allowed_record_types: str = Query(...)
|
||||
wallet: str = Query(...) # type: ignore
|
||||
domain: str = Query(...) # type: ignore
|
||||
cf_token: str = Query(...) # type: ignore
|
||||
cf_zone_id: str = Query(...) # type: ignore
|
||||
webhook: str = Query("") # type: ignore
|
||||
description: str = Query(..., min_length=0) # type: ignore
|
||||
cost: int = Query(..., ge=0) # type: ignore
|
||||
allowed_record_types: str = Query(...) # type: ignore
|
||||
|
||||
|
||||
class CreateSubdomain(BaseModel):
|
||||
domain: str = Query(...)
|
||||
subdomain: str = Query(...)
|
||||
email: str = Query(...)
|
||||
ip: str = Query(...)
|
||||
sats: int = Query(..., ge=0)
|
||||
duration: int = Query(...)
|
||||
record_type: str = Query(...)
|
||||
domain: str = Query(...) # type: ignore
|
||||
subdomain: str = Query(...) # type: ignore
|
||||
email: str = Query(...) # type: ignore
|
||||
ip: str = Query(...) # type: ignore
|
||||
sats: int = Query(..., ge=0) # type: ignore
|
||||
duration: int = Query(...) # type: ignore
|
||||
record_type: str = Query(...) # type: ignore
|
||||
|
||||
|
||||
class Domains(BaseModel):
|
||||
|
||||
@@ -20,7 +20,7 @@ async def wait_for_paid_invoices():
|
||||
|
||||
|
||||
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
|
||||
return
|
||||
|
||||
@@ -37,7 +37,7 @@ async def on_invoice_paid(payment: Payment) -> None:
|
||||
)
|
||||
|
||||
### Use webhook to notify about cloudflare registration
|
||||
if domain.webhook:
|
||||
if domain and domain.webhook:
|
||||
async with httpx.AsyncClient() as client:
|
||||
try:
|
||||
r = await client.post(
|
||||
|
||||
@@ -16,7 +16,9 @@ templates = Jinja2Templates(directory="templates")
|
||||
|
||||
|
||||
@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(
|
||||
"subdomains/index.html", {"request": request, "user": user.dict()}
|
||||
)
|
||||
|
||||
@@ -29,12 +29,15 @@ from .crud import (
|
||||
|
||||
@subdomains_ext.get("/api/v1/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]
|
||||
|
||||
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)]
|
||||
|
||||
@@ -42,7 +45,9 @@ async def api_domains(
|
||||
@subdomains_ext.post("/api/v1/domains")
|
||||
@subdomains_ext.put("/api/v1/domains/{domain_id}")
|
||||
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:
|
||||
domain = await get_domain(domain_id)
|
||||
@@ -63,7 +68,9 @@ async def api_domain_create(
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
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")
|
||||
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]
|
||||
|
||||
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)]
|
||||
|
||||
@@ -173,7 +182,9 @@ async def api_subdomain_send_subdomain(payment_hash):
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
if not subdomain:
|
||||
|
||||
Reference in New Issue
Block a user