fixup!
This commit is contained in:
parent
ed67ad3294
commit
bd355a8a01
6 changed files with 54 additions and 25 deletions
|
|
@ -53,7 +53,7 @@ def nostrclient_start():
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"db",
|
"db",
|
||||||
"nostrclient_ext",
|
"nostrclient_ext",
|
||||||
|
"nostrclient_start",
|
||||||
"nostrclient_static_files",
|
"nostrclient_static_files",
|
||||||
"nostrclient_stop",
|
"nostrclient_stop",
|
||||||
"nostrclient_start",
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
4
crud.py
4
crud.py
|
|
@ -1,5 +1,3 @@
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from lnbits.db import Database
|
from lnbits.db import Database
|
||||||
|
|
||||||
from .models import Config, Relay, UserConfig
|
from .models import Config, Relay, UserConfig
|
||||||
|
|
@ -40,7 +38,7 @@ async def update_config(owner_id: str, config: Config) -> Config:
|
||||||
return user_config.extra
|
return user_config.extra
|
||||||
|
|
||||||
|
|
||||||
async def get_config(owner_id: str) -> Optional[Config]:
|
async def get_config(owner_id: str) -> Config | None:
|
||||||
user_config: UserConfig = await db.fetchone(
|
user_config: UserConfig = await db.fetchone(
|
||||||
"""
|
"""
|
||||||
SELECT * FROM nostrclient.config
|
SELECT * FROM nostrclient.config
|
||||||
|
|
|
||||||
30
models.py
30
models.py
|
|
@ -1,27 +1,25 @@
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
class RelayStatus(BaseModel):
|
class RelayStatus(BaseModel):
|
||||||
num_sent_events: Optional[int] = 0
|
num_sent_events: int | None = 0
|
||||||
num_received_events: Optional[int] = 0
|
num_received_events: int | None = 0
|
||||||
error_counter: Optional[int] = 0
|
error_counter: int | None = 0
|
||||||
error_list: Optional[list] = []
|
error_list: list | None = []
|
||||||
notice_list: Optional[list] = []
|
notice_list: list | None = []
|
||||||
|
|
||||||
|
|
||||||
class Relay(BaseModel):
|
class Relay(BaseModel):
|
||||||
id: Optional[str] = None
|
id: str | None = None
|
||||||
url: Optional[str] = None
|
url: str | None = None
|
||||||
active: Optional[bool] = None
|
active: bool | None = None
|
||||||
|
|
||||||
connected: Optional[bool] = Field(default=None, no_database=True)
|
connected: bool | None = Field(default=None, no_database=True)
|
||||||
connected_string: Optional[str] = Field(default=None, no_database=True)
|
connected_string: str | None = Field(default=None, no_database=True)
|
||||||
status: Optional[RelayStatus] = Field(default=None, no_database=True)
|
status: RelayStatus | None = Field(default=None, no_database=True)
|
||||||
|
|
||||||
ping: Optional[int] = Field(default=None, no_database=True)
|
ping: int | None = Field(default=None, no_database=True)
|
||||||
|
|
||||||
def _init__(self):
|
def _init__(self):
|
||||||
if not self.id:
|
if not self.id:
|
||||||
|
|
@ -31,11 +29,11 @@ class Relay(BaseModel):
|
||||||
class RelayDb(BaseModel):
|
class RelayDb(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
url: str
|
url: str
|
||||||
active: Optional[bool] = True
|
active: bool | None = True
|
||||||
|
|
||||||
|
|
||||||
class TestMessage(BaseModel):
|
class TestMessage(BaseModel):
|
||||||
sender_private_key: Optional[str]
|
sender_private_key: str | None
|
||||||
reciever_public_key: str
|
reciever_public_key: str
|
||||||
message: str
|
message: str
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,21 @@ dev-dependencies = [
|
||||||
"pre-commit",
|
"pre-commit",
|
||||||
"ruff",
|
"ruff",
|
||||||
"pytest-md",
|
"pytest-md",
|
||||||
|
"types-cffi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
|
exclude = "(nostr/*)"
|
||||||
plugins = ["pydantic.mypy"]
|
plugins = ["pydantic.mypy"]
|
||||||
|
|
||||||
|
[[tool.mypy.overrides]]
|
||||||
|
module = [
|
||||||
|
"nostr.*",
|
||||||
|
"secp256k1.*",
|
||||||
|
]
|
||||||
|
follow_imports = "skip"
|
||||||
|
ignore_missing_imports = "True"
|
||||||
|
|
||||||
[tool.pydantic-mypy]
|
[tool.pydantic-mypy]
|
||||||
init_forbid_extra = true
|
init_forbid_extra = true
|
||||||
init_typed = true
|
init_typed = true
|
||||||
|
|
|
||||||
10
router.py
10
router.py
|
|
@ -1,6 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
from typing import ClassVar, Dict, List
|
from typing import ClassVar
|
||||||
|
|
||||||
from fastapi import WebSocket, WebSocketDisconnect
|
from fastapi import WebSocket, WebSocketDisconnect
|
||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
|
|
@ -16,7 +16,7 @@ all_routers: list["NostrRouter"] = []
|
||||||
|
|
||||||
|
|
||||||
class NostrRouter:
|
class NostrRouter:
|
||||||
received_subscription_events: ClassVar[dict[str, List[EventMessage]]] = {}
|
received_subscription_events: ClassVar[dict[str, list[EventMessage]]] = {}
|
||||||
received_subscription_notices: ClassVar[list[NoticeMessage]] = []
|
received_subscription_notices: ClassVar[list[NoticeMessage]] = []
|
||||||
received_subscription_eosenotices: ClassVar[dict[str, EndOfStoredEventsMessage]] = (
|
received_subscription_eosenotices: ClassVar[dict[str, EndOfStoredEventsMessage]] = (
|
||||||
{}
|
{}
|
||||||
|
|
@ -25,11 +25,11 @@ class NostrRouter:
|
||||||
def __init__(self, websocket: WebSocket):
|
def __init__(self, websocket: WebSocket):
|
||||||
self.connected: bool = True
|
self.connected: bool = True
|
||||||
self.websocket: WebSocket = websocket
|
self.websocket: WebSocket = websocket
|
||||||
self.tasks: List[asyncio.Task] = []
|
self.tasks: list[asyncio.Task] = []
|
||||||
self.original_subscription_ids: Dict[str, str] = {}
|
self.original_subscription_ids: dict[str, str] = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subscriptions(self) -> List[str]:
|
def subscriptions(self) -> list[str]:
|
||||||
return list(self.original_subscription_ids.keys())
|
return list(self.original_subscription_ids.keys())
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
|
|
||||||
23
uv.lock
generated
23
uv.lock
generated
|
|
@ -1087,6 +1087,7 @@ dev = [
|
||||||
{ name = "pytest-asyncio" },
|
{ name = "pytest-asyncio" },
|
||||||
{ name = "pytest-md" },
|
{ name = "pytest-md" },
|
||||||
{ name = "ruff" },
|
{ name = "ruff" },
|
||||||
|
{ name = "types-cffi" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
|
|
@ -1101,6 +1102,7 @@ dev = [
|
||||||
{ name = "pytest-asyncio" },
|
{ name = "pytest-asyncio" },
|
||||||
{ name = "pytest-md" },
|
{ name = "pytest-md" },
|
||||||
{ name = "ruff" },
|
{ name = "ruff" },
|
||||||
|
{ name = "types-cffi" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -2032,6 +2034,27 @@ wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/93/72/6b3e70d32e89a5cbb6a4513726c1ae8762165b027af569289e19ec08edd8/typer-0.17.4-py3-none-any.whl", hash = "sha256:015534a6edaa450e7007eba705d5c18c3349dcea50a6ad79a5ed530967575824", size = 46643, upload-time = "2025-09-05T18:14:39.166Z" },
|
{ url = "https://files.pythonhosted.org/packages/93/72/6b3e70d32e89a5cbb6a4513726c1ae8762165b027af569289e19ec08edd8/typer-0.17.4-py3-none-any.whl", hash = "sha256:015534a6edaa450e7007eba705d5c18c3349dcea50a6ad79a5ed530967575824", size = 46643, upload-time = "2025-09-05T18:14:39.166Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "types-cffi"
|
||||||
|
version = "1.17.0.20250822"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "types-setuptools" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/da/0c/76a48cb6e742cac4d61a4ec632dd30635b6d302f5acdc2c0a27572ac7ae3/types_cffi-1.17.0.20250822.tar.gz", hash = "sha256:bf6f5a381ea49da7ff895fae69711271e6192c434470ce6139bf2b2e0d0fa08d", size = 17130, upload-time = "2025-08-22T03:04:02.445Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/21/f7/68029931e7539e3246b33386a19c475f234c71d2a878411847b20bb31960/types_cffi-1.17.0.20250822-py3-none-any.whl", hash = "sha256:183dd76c1871a48936d7b931488e41f0f25a7463abe10b5816be275fc11506d5", size = 20083, upload-time = "2025-08-22T03:04:01.466Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "types-setuptools"
|
||||||
|
version = "80.9.0.20250822"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/19/bd/1e5f949b7cb740c9f0feaac430e301b8f1c5f11a81e26324299ea671a237/types_setuptools-80.9.0.20250822.tar.gz", hash = "sha256:070ea7716968ec67a84c7f7768d9952ff24d28b65b6594797a464f1b3066f965", size = 41296, upload-time = "2025-08-22T03:02:08.771Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b6/2d/475bf15c1cdc172e7a0d665b6e373ebfb1e9bf734d3f2f543d668b07a142/types_setuptools-80.9.0.20250822-py3-none-any.whl", hash = "sha256:53bf881cb9d7e46ed12c76ef76c0aaf28cfe6211d3fab12e0b83620b1a8642c3", size = 63179, upload-time = "2025-08-22T03:02:07.643Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typing-extensions"
|
name = "typing-extensions"
|
||||||
version = "4.14.0"
|
version = "4.14.0"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue