chore: code format
This commit is contained in:
parent
30ffcf7f55
commit
3aa4875558
3 changed files with 10 additions and 10 deletions
11
__init__.py
11
__init__.py
|
|
@ -21,17 +21,16 @@ nostrrelay_static_files = [
|
||||||
]
|
]
|
||||||
|
|
||||||
nostrrelay_redirect_paths = [
|
nostrrelay_redirect_paths = [
|
||||||
{
|
{
|
||||||
"from_path": "/",
|
"from_path": "/",
|
||||||
"redirect_to_path": "/api/v1/relay-info",
|
"redirect_to_path": "/api/v1/relay-info",
|
||||||
"header_filters": {
|
"header_filters": {"accept": "application/nostr+json"},
|
||||||
"accept": "application/nostr+json"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
scheduled_tasks: List[asyncio.Task] = []
|
scheduled_tasks: List[asyncio.Task] = []
|
||||||
|
|
||||||
|
|
||||||
def nostrrelay_renderer():
|
def nostrrelay_renderer():
|
||||||
return template_renderer(["lnbits/extensions/nostrrelay/templates"])
|
return template_renderer(["lnbits/extensions/nostrrelay/templates"])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,4 +34,4 @@ def relay_info_response(relay_public_data: dict) -> JSONResponse:
|
||||||
"Access-Control-Allow-Headers": "*",
|
"Access-Control-Allow-Headers": "*",
|
||||||
"Access-Control-Allow-Methods": "GET",
|
"Access-Control-Allow-Methods": "GET",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ async def api_toggle_relay(
|
||||||
) -> NostrRelay:
|
) -> NostrRelay:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
relay = await get_relay(wallet.wallet.user,relay_id)
|
relay = await get_relay(wallet.wallet.user, relay_id)
|
||||||
if not relay:
|
if not relay:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.NOT_FOUND,
|
status_code=HTTPStatus.NOT_FOUND,
|
||||||
|
|
@ -159,12 +159,13 @@ async def api_get_relays(
|
||||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||||
detail="Cannot fetch relays",
|
detail="Cannot fetch relays",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@nostrrelay_ext.get("/api/v1/relay-info")
|
@nostrrelay_ext.get("/api/v1/relay-info")
|
||||||
async def api_get_relay_info() -> JSONResponse:
|
async def api_get_relay_info() -> JSONResponse:
|
||||||
return relay_info_response(NostrRelay.info())
|
return relay_info_response(NostrRelay.info())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@nostrrelay_ext.get("/api/v1/relay/{relay_id}")
|
@nostrrelay_ext.get("/api/v1/relay/{relay_id}")
|
||||||
async def api_get_relay(
|
async def api_get_relay(
|
||||||
relay_id: str, wallet: WalletTypeInfo = Depends(require_invoice_key)
|
relay_id: str, wallet: WalletTypeInfo = Depends(require_invoice_key)
|
||||||
|
|
@ -288,7 +289,7 @@ async def api_pay_to_join(data: BuyOrder):
|
||||||
if data.action == "join":
|
if data.action == "join":
|
||||||
if relay.is_free_to_join:
|
if relay.is_free_to_join:
|
||||||
raise ValueError("Relay is free to join")
|
raise ValueError("Relay is free to join")
|
||||||
amount = int(relay.config.cost_to_join)
|
amount = int(relay.config.cost_to_join)
|
||||||
elif data.action == "storage":
|
elif data.action == "storage":
|
||||||
if relay.config.storage_cost_value == 0:
|
if relay.config.storage_cost_value == 0:
|
||||||
raise ValueError("Relay storage cost is zero. Cannot buy!")
|
raise ValueError("Relay storage cost is zero. Cannot buy!")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue