fix not logging when user accessed they files and only show the file access from the user files and not all
Build and Push Docker Container / build-and-push (push) Successful in 1m37s

This commit is contained in:
2025-10-25 14:54:00 +02:00
parent 6f92fdefa9
commit cd96e9135f
4 changed files with 47 additions and 7 deletions
+4 -4
View File
@@ -19,7 +19,7 @@ async def index():
@side_main_bp.route('/access')
@login_required
async def access_list(user):
access_data = await current_app.edgedb.get_all_file_access()
access_data = await current_app.edgedb.get_all_access_of_user(user_id=user['sub'])
return await render_template("views/webpage/access/list.htm", access_logs=access_data)
@side_main_bp.route('/files')
@@ -54,7 +54,7 @@ async def serve_file(file_id: str):
disable_logging = True
if is_expired(file_data.get("expires_at")):
if disable_logging:
if not disable_logging:
await current_app.edgedb.add_file_access(file_id=file_id, ip_address=get_ip(), user_agent=request.user_agent, status="expired", accessed_at=datetime.now(timezone.utc))
return Response("This file has expired.", status=410, headers={
"Cache-Control": "no-store",
@@ -68,11 +68,11 @@ async def serve_file(file_id: str):
path = current_app.upload_folder / file_name
if not path.exists() or not path.is_file():
if disable_logging:
if not disable_logging:
await current_app.edgedb.add_file_access(file_id=file_id, ip_address=get_ip(), user_agent=request.user_agent, status="error", accessed_at=datetime.now(timezone.utc))
abort(404)
if disable_logging:
if not disable_logging:
await current_app.edgedb.add_file_access(file_id=file_id, ip_address=get_ip(), user_agent=request.user_agent, status="ok", accessed_at=datetime.now(timezone.utc))
return await send_from_directory(
directory=current_app.upload_folder,