Man, broken
This commit is contained in:
+3
-3
@@ -626,11 +626,11 @@ async def create_admin_settings(super_user: str, new_settings: dict):
|
||||
# -------
|
||||
|
||||
|
||||
async def create_tinyurl(domain: str, conn: Optional[Connection] = None):
|
||||
async def create_tinyurl(domain: str, endless: bool, conn: Optional[Connection] = None):
|
||||
tinyurl_id = uuid4().hex[:8]
|
||||
await (conn or db).execute(
|
||||
f"INSERT INTO tiny_url (id, url) VALUES (?, ?)",
|
||||
(tinyurl_id, domain),
|
||||
f"INSERT INTO tiny_url (id, url, endless) VALUES (?, ?, ?)",
|
||||
(tinyurl_id, domain, endless,),
|
||||
)
|
||||
return await get_tinyurl(tinyurl_id)
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ async def m009_create_tinyurl_table(db):
|
||||
id TEXT PRIMARY KEY,
|
||||
url TEXT,
|
||||
endless BOOL NOT NULL DEFAULT false,
|
||||
time TIMESTAMP NOT NULL DEFAULT {db.timestamp_now},
|
||||
time TIMESTAMP NOT NULL DEFAULT {db.timestamp_now}
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -223,4 +223,4 @@ class TinyURL(BaseModel):
|
||||
|
||||
@classmethod
|
||||
def from_row(cls, row: Row):
|
||||
return cls(id=row["id"], url=row["url"])
|
||||
return cls(dict(row))
|
||||
|
||||
@@ -715,11 +715,11 @@ async def websocket_update_get(item_id: str, data: str):
|
||||
|
||||
|
||||
@core_app.post("/api/v1/tinyurl")
|
||||
async def api_create_tinyurl(url: str):
|
||||
async def api_create_tinyurl(url: str, endless: Optional[bool] = False):
|
||||
tinyurl = await get_tinyurl_by_url(url)
|
||||
if tinyurl:
|
||||
return tinyurl
|
||||
return await create_tinyurl(url)
|
||||
return await create_tinyurl(url, endless)
|
||||
|
||||
|
||||
@core_app.get("/api/v1/tinyurl/{tinyurl_id}")
|
||||
|
||||
Reference in New Issue
Block a user