diff --git a/__init__.py b/__init__.py index 5df0dec..7884f91 100644 --- a/__init__.py +++ b/__init__.py @@ -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() +} diff --git a/crud.py b/crud.py index 612bcfd..629bf91 100644 --- a/crud.py +++ b/crud.py @@ -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 } diff --git a/models.py b/models.py index f43153e..6f703fd 100644 --- a/models.py +++ b/models.py @@ -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))