mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-20 10:39:59 +01:00
e73a508011
- make remember cookie optional - improve database - improve type casting
24 lines
507 B
Python
24 lines
507 B
Python
import json
|
|
|
|
from sqlite3 import Row
|
|
from typing import NamedTuple, Optional
|
|
|
|
|
|
class Paywall(NamedTuple):
|
|
id: str
|
|
wallet: str
|
|
url: str
|
|
memo: str
|
|
description: str
|
|
amount: int
|
|
time: int
|
|
remembers: bool
|
|
extras: Optional[dict]
|
|
|
|
@classmethod
|
|
def from_row(cls, row: Row) -> "Paywall":
|
|
data = dict(row)
|
|
data["remembers"] = bool(data["remembers"])
|
|
data["extras"] = json.loads(data["extras"]) if data["extras"] else None
|
|
return cls(**data)
|