mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-22 03:49:18 +02:00
fix: attribute direct library prints to the authenticated user
The library POST /files/{file_id}/print endpoint discarded the
authenticated user and passed requested_by_user_id=None to the
dispatcher, so archives created from direct prints had no
created_by_id and didn't show up in per-user statistics. Queue
and reprint paths already forwarded the user correctly.
Bind the auth dependency to current_user and pass its id/username
through to dispatch_print_library_file, matching the reprint
endpoint. The dispatcher already propagates this to
printer_manager.set_current_print_user, which the archive
creation reads.
This commit is contained in:
@@ -2169,7 +2169,7 @@ async def print_library_file(
|
||||
printer_id: int,
|
||||
body: FilePrintRequest | None = None,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
_: User | None = Depends(require_permission_if_auth_enabled(Permission.PRINTERS_CONTROL)),
|
||||
current_user: User | None = Depends(require_permission_if_auth_enabled(Permission.PRINTERS_CONTROL)),
|
||||
):
|
||||
"""Dispatch a library file for send/start on a printer.
|
||||
|
||||
@@ -2238,8 +2238,8 @@ async def print_library_file(
|
||||
printer_name=printer.name,
|
||||
options=body.model_dump(exclude_none=True),
|
||||
project_id=body.project_id,
|
||||
requested_by_user_id=None,
|
||||
requested_by_username=None,
|
||||
requested_by_user_id=current_user.id if current_user else None,
|
||||
requested_by_username=current_user.username if current_user else None,
|
||||
)
|
||||
except DispatchEnqueueRejected as e:
|
||||
raise HTTPException(status_code=409, detail=str(e)) from e
|
||||
|
||||
Reference in New Issue
Block a user