admin check and thread as daemon

This commit is contained in:
callebtc 2023-02-17 16:13:06 +01:00
parent dfe15f6673
commit d504146f91
4 changed files with 18 additions and 14 deletions

View file

@ -57,7 +57,9 @@ async def api_get_relays(): # type: ignore
return relays
@nostrclient_ext.post("/api/v1/relay")
@nostrclient_ext.post(
"/api/v1/relay", status_code=HTTPStatus.OK, dependencies=[Depends(check_admin)]
)
async def api_add_relay(relay: Relay): # type: ignore
assert relay.url, "no URL"
if relay.url in client.relay_manager.relays:
@ -67,7 +69,9 @@ async def api_add_relay(relay: Relay): # type: ignore
await init_relays()
@nostrclient_ext.delete("/api/v1/relay")
@nostrclient_ext.delete(
"/api/v1/relay", status_code=HTTPStatus.OK, dependencies=[Depends(check_admin)]
)
async def api_delete_relay(relay: Relay): # type: ignore
assert relay.url
client.relay_manager.remove_relay(relay.url)