feat: init lnbits_relay_information
This commit is contained in:
parent
e4197ce66d
commit
4c9d1a4395
3 changed files with 22 additions and 6 deletions
|
|
@ -3,6 +3,7 @@ from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
from lnbits.db import Database
|
from lnbits.db import Database
|
||||||
from lnbits.helpers import template_renderer
|
from lnbits.helpers import template_renderer
|
||||||
|
from lnbits.settings import settings
|
||||||
|
|
||||||
db = Database("ext_nostrrelay")
|
db = Database("ext_nostrrelay")
|
||||||
|
|
||||||
|
|
@ -23,3 +24,10 @@ def nostrrelay_renderer():
|
||||||
|
|
||||||
from .views import * # noqa
|
from .views import * # noqa
|
||||||
from .views_api 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()
|
||||||
|
}
|
||||||
|
|
|
||||||
4
crud.py
4
crud.py
|
|
@ -54,12 +54,12 @@ async def get_public_relay(relay_id: str) -> Optional[dict]:
|
||||||
|
|
||||||
relay = NostrRelay.from_row(row)
|
relay = NostrRelay.from_row(row)
|
||||||
return {
|
return {
|
||||||
|
**NostrRelay.info(),
|
||||||
"id": relay.id,
|
"id": relay.id,
|
||||||
"name": relay.name,
|
"name": relay.name,
|
||||||
"description":relay.description,
|
"description":relay.description,
|
||||||
"pubkey":relay.pubkey,
|
"pubkey":relay.pubkey,
|
||||||
"contact":relay.contact,
|
"contact":relay.contact
|
||||||
"supported_nips":relay.supported_nips,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
16
models.py
16
models.py
|
|
@ -13,13 +13,21 @@ class NostrRelay(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
description: Optional[str]
|
description: Optional[str]
|
||||||
pubkey: Optional[str]
|
pubkey: Optional[str]
|
||||||
contact: Optional[str] = "https://t.me/lnbits"
|
contact: Optional[str]
|
||||||
active: bool = False
|
active: bool = False
|
||||||
supported_nips: List[str] = ["NIP01", "NIP09", "NIP11", "NIP15", "NIP20"]
|
|
||||||
software: Optional[str] = "LNbist"
|
|
||||||
version: Optional[str]
|
|
||||||
# meta: 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
|
@classmethod
|
||||||
def from_row(cls, row: Row) -> "NostrRelay":
|
def from_row(cls, row: Row) -> "NostrRelay":
|
||||||
return cls(**dict(row))
|
return cls(**dict(row))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue