Gib verknüpfte Originale im Datenraum je Person über die eigenen Zugänge frei, damit Raummitglieder Paperless-Dokumente und E-Mails geteilter Akten lesen können.
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Successful in 6m39s
Test Suite / frontend-build (push) Successful in 24s
Test Suite / smoke-dev (push) Successful in 0s

Die Raumfreigabe allein gab die Zugänge des Owners nicht weiter. Ein Leser im Raum sah die Akte,
aber kein Original. Neu ist room_source_access: Wer im Raum teilen darf, schaltet für ein Mitglied
„Originale über meine Zugänge“ ein. Das gilt für alle eigenen, mit dem Raum geteilten Einträge.
Ausnahmen, Ende der Raumfreigabe und Verlassen des Raums schließen den Abruf. Beschluss R-01 ist
entsprechend ergänzt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-04 15:19:15 +01:00
1 parent 363ecdfd0a
commit 15e0dc7e52
15 files changed
+362 -13

No files matched your search

+86
View File
@@ -30,6 +30,7 @@ from app.api.schemas import (
OwnerIn,
RoomIn,
RoomPatchIn,
SourceAccessIn,
VisibilityIn,
)
from app.auth.accounts import normalize_email
@@ -114,6 +115,27 @@ def _drop_shares_of(conn, room_id: UUID, subject_id: UUID) -> None:
""",
(room_id, subject_id, subject_id),
)
# Without own shares in the room there is nothing left to lend.
conn.execute(
"DELETE FROM room_source_access WHERE room_id = %s AND owner_id = %s",
(room_id, subject_id),
)
def _drop_source_access_to(conn, room_id: UUID, subject_id: UUID) -> None:
"""A person who leaves the team loses every source access lent to them there. A return starts without it."""
conn.execute(
"DELETE FROM room_source_access WHERE room_id = %s AND subject_id = %s",
(room_id, subject_id),
)
def _lent_to(conn, room_id: UUID, owner_id: UUID) -> set[UUID]:
rows = conn.execute(
"SELECT subject_id FROM room_source_access WHERE room_id = %s AND owner_id = %s",
(room_id, owner_id),
).fetchall()
return {row["subject_id"] for row in rows}
def _set_role(conn, actor: UUID, room_id: UUID, subject_id: UUID, role: str, *, added: bool) -> None:
@@ -391,6 +413,7 @@ def members(room_id: UUID, principal: Principal = Depends(get_principal), conn:
""",
(room_id,),
).fetchall()
lent = _lent_to(conn, room_id, principal.account_id)
return {
"items": [
{
@@ -400,6 +423,8 @@ def members(room_id: UUID, principal: Principal = Depends(get_principal), conn:
"role": row["role"],
"account_status": row["status"],
"is_owner": row["subject_id"] == owner_id,
"is_self": row["subject_id"] == principal.account_id,
"my_sources": row["subject_id"] in lent,
}
for row in rows
]
@@ -472,6 +497,7 @@ def remove_member(
(room_id, subject_id),
)
_drop_shares_of(conn, room_id, subject_id)
_drop_source_access_to(conn, room_id, subject_id)
# The removed person works in the personal room again; own entries stay visible there.
conn.execute(
"""
@@ -485,6 +511,66 @@ def remove_member(
return Response(status_code=204)
@router.put("/api/v1/rooms/{room_id}/source-access/{subject_id}")
def put_source_access(
room_id: UUID,
subject_id: UUID,
body: SourceAccessIn,
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
"""Lend the own connectors to one member for the own entries shared with this room.
Only the person whose connectors are used decides. That is anyone who may share into the room.
"""
actor = principal.account_id
room = conn.execute(
"SELECT id, status FROM data_rooms WHERE id = %s AND kind = 'organization'", (room_id,)
).fetchone()
if room is None or room_role(conn, actor, room_id) is None:
raise not_found()
if room["status"] != "active":
raise unprocessable("Der Datenraum ist archiviert.")
if room_role(conn, actor, room_id) not in {"member", "manager"}:
raise forbidden("Quellen gibt frei, wer in diesem Datenraum teilen darf.")
if subject_id == actor:
raise unprocessable("Die eigenen Zugänge brauchen keine Freigabe.")
if room_role(conn, subject_id, room_id) is None:
raise not_found()
if body.enabled:
created = conn.execute(
"""
INSERT INTO room_source_access (room_id, owner_id, subject_id)
VALUES (%s, %s, %s)
ON CONFLICT DO NOTHING
RETURNING subject_id
""",
(room_id, actor, subject_id),
).fetchone()
changed = created is not None
else:
removed = conn.execute(
"""
DELETE FROM room_source_access
WHERE room_id = %s AND owner_id = %s AND subject_id = %s
RETURNING subject_id
""",
(room_id, actor, subject_id),
).fetchone()
changed = removed is not None
if changed:
audit(
conn,
actor,
room_id,
"room_source_access_granted" if body.enabled else "room_source_access_revoked",
"membership",
subject_id,
detail={"room_id": str(room_id)},
)
return {"subject_id": str(subject_id), "enabled": body.enabled}
@router.post("/api/v1/invitations")
def invite(
body: InvitationIn,
+6
View File
@@ -37,6 +37,11 @@ def _view(conn, actor: UUID, kind: str, resource_id: UUID) -> dict:
(kind, resource_id),
).fetchall()
result = []
lent = conn.execute(
"SELECT room_id, subject_id FROM room_source_access WHERE owner_id = %s",
(actor,),
).fetchall()
lent_pairs = {(row["room_id"], row["subject_id"]) for row in lent}
for share in shares:
members = conn.execute(
"""
@@ -65,6 +70,7 @@ def _view(conn, actor: UUID, kind: str, resource_id: UUID) -> dict:
"display_name": row["display_name"],
"role": row["role"],
"excluded": row["excluded"],
"sources": (share["room_id"], row["subject_id"]) in lent_pairs,
"rights": {
"read": _capped(row["role"], share["access"]).read,
"edit": _capped(row["role"], share["access"]).edit,
+4
View File
@@ -95,6 +95,10 @@ class ExclusionIn(APIModel):
excluded: bool
class SourceAccessIn(APIModel):
enabled: bool
class OwnerIn(APIModel):
subject_id: UUID