feat: init lnbits_relay_information

This commit is contained in:
Vlad Stan 2023-02-07 12:21:23 +02:00
parent e4197ce66d
commit 4c9d1a4395
3 changed files with 22 additions and 6 deletions

View file

@ -3,6 +3,7 @@ from fastapi.staticfiles import StaticFiles
from lnbits.db import Database
from lnbits.helpers import template_renderer
from lnbits.settings import settings
db = Database("ext_nostrrelay")
@ -23,3 +24,10 @@ def nostrrelay_renderer():
from .views import * # noqa
from .views_api import * # noqa
from .models import NostrRelay
settings.lnbits_relay_information = {
"name": "LNbits Nostr Relay",
"description": "Multiple relays are supported",
**NostrRelay.info()
}

View file

@ -54,12 +54,12 @@ async def get_public_relay(relay_id: str) -> Optional[dict]:
relay = NostrRelay.from_row(row)
return {
**NostrRelay.info(),
"id": relay.id,
"name": relay.name,
"description":relay.description,
"pubkey":relay.pubkey,
"contact":relay.contact,
"supported_nips":relay.supported_nips,
"contact":relay.contact
}

View file

@ -13,13 +13,21 @@ class NostrRelay(BaseModel):
name: str
description: Optional[str]
pubkey: Optional[str]
contact: Optional[str] = "https://t.me/lnbits"
contact: Optional[str]
active: bool = False
supported_nips: List[str] = ["NIP01", "NIP09", "NIP11", "NIP15", "NIP20"]
software: Optional[str] = "LNbist"
version: Optional[str]
# meta: Optional[str]
@classmethod
def info(cls,) -> dict:
return {
"contact": "https://t.me/lnbits",
"supported_nips": [1, 9, 11, 15, 20],
"software": "LNbits",
"version": "",
}
@classmethod
def from_row(cls, row: Row) -> "NostrRelay":
return cls(**dict(row))