Stabilize (#24)

* refactor: clean-up

* refactor: extra logs plus try-catch

* refactor: do not use bare `except`

* refactor: clean-up redundant fields

* chore: pass code checks

* chore: code format

* refactor: code clean-up

* fix: refactoring stuff

* refactor: remove un-used file

* chore: code clean-up

* chore: code clean-up

* chore: code-format fix

* refactor: remove nostr.client wrapper

* refactor: code clean-up

* chore: code format

* refactor: remove `RelayList` class

* refactor: extract smaller methods with try-catch

* fix: better exception handling

* fix: remove redundant filters

* fix: simplify event

* chore: code format

* fix: code check

* fix: code check

* fix: simplify `REQ`

* fix: more clean-ups

* refactor: use simpler method

* refactor: re-order and rename

* fix: stop logic

* fix: subscription close before disconnect

* chore: play commit
This commit is contained in:
Vlad Stan 2023-11-01 17:46:42 +02:00 committed by GitHub
parent ab185bd2c4
commit 16ae9d15a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 522 additions and 717 deletions

View file

@ -1,9 +1,7 @@
from dataclasses import dataclass
from typing import Dict, List, Optional
from sqlite3 import Row
from typing import List, Optional
from fastapi import Request
from fastapi.param_functions import Query
from pydantic import BaseModel, Field
from pydantic import BaseModel
from lnbits.helpers import urlsafe_short_hash
@ -14,7 +12,8 @@ class RelayStatus(BaseModel):
error_counter: Optional[int] = 0
error_list: Optional[List] = []
notice_list: Optional[List] = []
class Relay(BaseModel):
id: Optional[str] = None
url: Optional[str] = None
@ -28,33 +27,9 @@ class Relay(BaseModel):
if not self.id:
self.id = urlsafe_short_hash()
class RelayList(BaseModel):
__root__: List[Relay]
class Event(BaseModel):
content: str
pubkey: str
created_at: Optional[int]
kind: int
tags: Optional[List[List[str]]]
sig: str
class Filter(BaseModel):
ids: Optional[List[str]]
kinds: Optional[List[int]]
authors: Optional[List[str]]
since: Optional[int]
until: Optional[int]
e: Optional[List[str]] = Field(alias="#e")
p: Optional[List[str]] = Field(alias="#p")
limit: Optional[int]
class Filters(BaseModel):
__root__: List[Filter]
@classmethod
def from_row(cls, row: Row) -> "Relay":
return cls(**dict(row))
class TestMessage(BaseModel):
@ -62,6 +37,7 @@ class TestMessage(BaseModel):
reciever_public_key: str
message: str
class TestMessageResponse(BaseModel):
private_key: str
public_key: str