Skip to content

Commit

Permalink
file not found fixes & discord bot updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Andcool-Systems committed Feb 25, 2024
1 parent ebb9201 commit fea1957
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
/.env
/out
/Telegram_provider/dataBase.db
/Telegram_provider/.env
/Telegram_provider/.env
/FileUploaderBot/.env
2 changes: 1 addition & 1 deletion FileUploaderBot
Submodule FileUploaderBot updated 2 files
+2 −1 .gitignore
+138 −49 main.py
11 changes: 5 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"}
Expand Down
1 change: 0 additions & 1 deletion schema.prisma
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
datasource db {
// could be postgresql or mysql
provider = "sqlite"
url = "file:dataBase.db"
}
Expand Down
3 changes: 1 addition & 2 deletions web/tos/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ body{
color: #eeeeee;
height: 100%;
overflow-x: hidden;
margin: 0%;
}

main{
Expand All @@ -24,8 +25,6 @@ hr{
}
p{margin-left: 2px;}



nav a{
cursor: pointer;
color: white;
Expand Down

0 comments on commit fea1957

Please sign in to comment.