chore: code format
This commit is contained in:
parent
8678090e7b
commit
ebada934b0
6 changed files with 32 additions and 29 deletions
19
models.py
19
models.py
|
|
@ -11,10 +11,13 @@ from secp256k1 import PublicKey
|
|||
class Spec(BaseModel):
|
||||
class Config:
|
||||
allow_population_by_field_name = True
|
||||
|
||||
|
||||
class FilterSpec(Spec):
|
||||
max_client_filters = Field(0, alias="maxClientFilters")
|
||||
limit_per_filter = Field(1000, alias="limitPerFilter")
|
||||
|
||||
|
||||
class EventSpec(Spec):
|
||||
max_events_per_second = Field(0, alias="maxEventsPerSecond")
|
||||
|
||||
|
|
@ -28,7 +31,6 @@ class EventSpec(Spec):
|
|||
created_at_minutes_future = Field(0, alias="createdAtMinutesFuture")
|
||||
created_at_seconds_future = Field(0, alias="createdAtSecondsFuture")
|
||||
|
||||
|
||||
@property
|
||||
def created_at_in_past(self) -> int:
|
||||
return (
|
||||
|
|
@ -47,6 +49,7 @@ class EventSpec(Spec):
|
|||
+ self.created_at_seconds_future
|
||||
)
|
||||
|
||||
|
||||
class StorageSpec(Spec):
|
||||
free_storage_value = Field(1, alias="freeStorageValue")
|
||||
free_storage_unit = Field("MB", alias="freeStorageUnit")
|
||||
|
|
@ -59,6 +62,7 @@ class StorageSpec(Spec):
|
|||
value *= 1024
|
||||
return value
|
||||
|
||||
|
||||
class AuthorSpec(Spec):
|
||||
allowed_public_keys = Field([], alias="allowedPublicKeys")
|
||||
blocked_public_keys = Field([], alias="blockedPublicKeys")
|
||||
|
|
@ -78,15 +82,22 @@ class PaymentSpec(BaseModel):
|
|||
|
||||
storage_cost_value = Field(0, alias="storageCostValue")
|
||||
storage_cost_unit = Field("MB", alias="storageCostUnit")
|
||||
|
||||
|
||||
class WalletSpec(Spec):
|
||||
wallet = Field("")
|
||||
|
||||
class RelaySpec(FilterSpec, EventSpec, StorageSpec, AuthorSpec, PaymentSpec, WalletSpec):
|
||||
|
||||
class RelaySpec(
|
||||
FilterSpec, EventSpec, StorageSpec, AuthorSpec, PaymentSpec, WalletSpec
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
class RelayPublicSpec(FilterSpec, EventSpec, StorageSpec, PaymentSpec):
|
||||
pass
|
||||
|
||||
|
||||
class NostrRelay(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
|
|
@ -99,7 +110,7 @@ class NostrRelay(BaseModel):
|
|||
|
||||
@property
|
||||
def is_free_to_join(self):
|
||||
return not self.config.is_paid_relay or self.config.cost_to_join == 0
|
||||
return not self.config.is_paid_relay or self.config.cost_to_join == 0
|
||||
|
||||
@classmethod
|
||||
def from_row(cls, row: Row) -> "NostrRelay":
|
||||
|
|
@ -298,4 +309,4 @@ class NostrFilter(BaseModel):
|
|||
|
||||
class RelayJoin(BaseModel):
|
||||
relay_id: str
|
||||
pubkey: str
|
||||
pubkey: str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue