From fea1957b8ecbcf36e06ad82517fb500a08e878dc Mon Sep 17 00:00:00 2001 From: AndcoolSystems Date: Sun, 25 Feb 2024 11:51:15 +0300 Subject: [PATCH] file not found fixes & discord bot updates --- .gitignore | 3 ++- FileUploaderBot | 2 +- main.py | 11 +++++------ schema.prisma | 1 - web/tos/style.css | 3 +-- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index d574c04..7198ba9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /.env /out /Telegram_provider/dataBase.db -/Telegram_provider/.env \ No newline at end of file +/Telegram_provider/.env +/FileUploaderBot/.env \ No newline at end of file diff --git a/FileUploaderBot b/FileUploaderBot index 789378f..bda439f 160000 --- a/FileUploaderBot +++ b/FileUploaderBot @@ -1 +1 @@ -Subproject commit 789378f2c02c11674b79f12fb93996013dbcccc7 +Subproject commit bda439fb626dfe4d2e3643162c6ec7c14e782723 diff --git a/main.py b/main.py index 7b7dc5b..3aebf16 100644 --- a/main.py +++ b/main.py @@ -228,7 +228,7 @@ async def upload_file( @limiter.limit(dynamic_limit_provider) async def send_file(url: str, request: Request): result = await db.file.find_first(where={"url": url}) # Get file by url - if not result: + if not result or not os.path.isfile(result.filename): async with aiofiles.open("404.html", mode="rb") as f: return Response( await f.read(), media_type="text/html", status_code=404 @@ -271,7 +271,7 @@ async def delete_file(url: str, key: str = ""): result = await db.file.find_first(where={"url": url}) # Get file record by url if not result: return JSONResponse( - content={"status": "error", "message": "File not found"}, status_code=200 + content={"status": "error", "message": "File not found"}, status_code=404 ) # if file does'n exists if result.key == key: # If provided key matched with key from database record @@ -568,6 +568,7 @@ async def login(code: str, status_code=200, ) + @app.post("/api/login") # login handler @limiter.limit(dynamic_limit_provider) async def login(request: Request, bot: bool = False, user_agent: Union[str, None] = Header(default=None)): @@ -625,8 +626,6 @@ async def login(request: Request, bot: bool = False, user_agent: Union[str, None "accessTokenSecret", algorithm="HS256", ) - #if len(user.tokens) > 10: # If user have more than 10 tokens - # await db.token.delete_many(where={"user_id": user.id}) await db.token.create( { # Create token record in db @@ -679,8 +678,8 @@ async def refresh_token(request: Request, user_agent: Union[str, None] = Header( "accessTokenSecret", algorithm="HS256", ) # Generate new token - await db.token.update( - where={"id": token_db.id}, data={"accessToken": access} # Replace old token + await db.token.update(where={"id": token_db.id}, + data={"accessToken": access} # Replace old token ) return {"status": "success", "accessToken": access, "message": "token refreshed"} diff --git a/schema.prisma b/schema.prisma index 079a3a6..3c97471 100644 --- a/schema.prisma +++ b/schema.prisma @@ -1,5 +1,4 @@ datasource db { - // could be postgresql or mysql provider = "sqlite" url = "file:dataBase.db" } diff --git a/web/tos/style.css b/web/tos/style.css index e000847..1e50c8a 100644 --- a/web/tos/style.css +++ b/web/tos/style.css @@ -7,6 +7,7 @@ body{ color: #eeeeee; height: 100%; overflow-x: hidden; + margin: 0%; } main{ @@ -24,8 +25,6 @@ hr{ } p{margin-left: 2px;} - - nav a{ cursor: pointer; color: white;