This commit is contained in:
+8
-2
@@ -24,6 +24,12 @@ def find_file(files: list[dict], file_id: str):
|
||||
return file_data
|
||||
return None
|
||||
|
||||
def build_share_url(file_id: str) -> str:
|
||||
scheme = (request.headers.get("X-Forwarded-Proto") or request.scheme or "http").split(",")[0].strip()
|
||||
host = (request.headers.get("X-Forwarded-Host") or request.host).split(",")[0].strip()
|
||||
root_path = request.root_path.rstrip("/")
|
||||
return f"{scheme}://{host}{root_path}/-{file_id}"
|
||||
|
||||
@side_main_bp.route('/')
|
||||
@LIMITER.limit("10 per minute;50 per hour")
|
||||
async def index():
|
||||
@@ -54,7 +60,7 @@ async def file_info(file_id, user):
|
||||
abort(404)
|
||||
|
||||
access_data = await current_app.convex.get_file_access(file_id=file_id, user_id=user["sub"]) or []
|
||||
share_url = request.url_root.rstrip("/") + f"/-{file_id}"
|
||||
share_url = build_share_url(file_id)
|
||||
return await render_template(
|
||||
"views/webpage/files/info.htm",
|
||||
file=file_data,
|
||||
@@ -69,7 +75,7 @@ async def file_edit(file_id, user):
|
||||
if not file_data:
|
||||
abort(404)
|
||||
|
||||
share_url = request.url_root.rstrip("/") + f"/-{file_id}"
|
||||
share_url = build_share_url(file_id)
|
||||
return await render_template(
|
||||
"views/webpage/files/edit.htm", file=file_data, share_url=share_url, file_id=file_id
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user