Release v0.1.3

This commit is contained in:
2026-06-26 01:39:18 +02:00
parent 189e950589
commit a7895ad394
9 changed files with 356 additions and 91 deletions

View File

@@ -16,6 +16,8 @@ from govoplan_core.auth.dependencies import ApiPrincipal, has_scope, require_sco
from govoplan_core.core.optional import reraise_unless_missing_package
from govoplan_files.backend.schemas import (
ArchiveRequest,
BulkFileShareRequest,
BulkFileShareResponse,
BulkDeleteRequest,
BulkDeleteResponse,
ConflictResolutionRequest,
@@ -57,6 +59,7 @@ from govoplan_files.backend.storage.files import (
list_assets_for_user,
read_asset_bytes,
share_file,
share_files,
soft_delete_assets,
)
from govoplan_files.backend.storage.folders import create_folder, list_folders_for_user, soft_delete_folder
@@ -547,6 +550,48 @@ def create_share(
raise _http_error(exc) from exc
@router.post("/bulk-shares", response_model=BulkFileShareResponse)
def create_bulk_shares(
payload: BulkFileShareRequest,
session: Session = Depends(get_session),
principal: ApiPrincipal = Depends(require_scope("files:file:share")),
):
try:
file_ids = list(dict.fromkeys(payload.file_ids))
assets = [
get_asset_for_user(session, tenant_id=principal.tenant_id, user_id=principal.user.id, asset_id=file_id, require_write=True, is_admin=_is_admin(principal))
for file_id in file_ids
]
shares = share_files(
session,
tenant_id=principal.tenant_id,
assets=assets,
target_type=payload.target_type,
target_id=payload.target_id,
permission=payload.permission,
user_id=principal.user.id,
)
session.commit()
return BulkFileShareResponse(
shared_count=len(shares),
shares=[
FileShareResponse(
id=share.id,
target_type=share.target_type,
target_id=share.target_id,
permission=share.permission,
created_at=share.created_at.isoformat(),
revoked_at=share.revoked_at.isoformat() if share.revoked_at else None,
)
for share in shares
],
)
except FileStorageError as exc:
session.rollback()
raise _http_error(exc) from exc
@router.post("/bulk-rename", response_model=RenameResponse)
def bulk_rename(
payload: RenameRequest,