Führe Raum-Eigentümer und Raumfreigabe ein, damit aus einem privaten Raum ein Mehrbenutzer-Raum wird.

Jeder Datenraum hat einen Eigentümer, der Verwalter bleibt, den Raum übertragen kann und im Notfall vom Betreiber ersetzt wird. Neue Akten und Vorgänge folgen der Voreinstellung des Raums: Bei "im Raum teilen" lesen Leser sie und bearbeiten Mitglieder und Verwalter; Weitergeben und Löschen bleiben beim Owner, der eine Akte privat stellen oder einzelne Personen ausnehmen kann. Bestehende Akten bleiben privat. Beim ersten weiteren Mitglied zeigt die Oberfläche, was sichtbar wird.

Das Löschen von Akte und Vorgang verlangt jetzt den Owner statt nur das Bearbeitungsrecht und schließt damit R-01. Die Rechte der Raumfreigabe gelten nur bei aktivem Raum, aktiver Mitgliedschaft und aktivem Konto.

Die lokale Suite läuft mit 128 Tests grün, der Frontend-Build und 19 Node-Tests ebenfalls. Die Oberfläche wurde noch nicht im Browser bedient.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-10-20 15:40:30 +02:00
1 parent 037c0724a8
commit 1c2f045e7d
25 files changed
+1088 -61

No files matched your search

+65 -2
View File
@@ -35,6 +35,14 @@ class Rights:
return cls()
return cls(bool(row["can_read"]), bool(row["can_edit"]), bool(row["can_share"]), bool(row["can_delete"]))
def union(self, other: Rights) -> Rights:
return Rights(
self.read or other.read,
self.edit or other.edit,
self.share or other.share,
self.delete or other.delete,
)
def without(self, blocked: Rights) -> Rights:
return Rights(
self.read and not blocked.read,
@@ -50,6 +58,15 @@ class Rights:
return {"read": self.read, "edit": self.edit, "share": self.share, "delete": self.delete}
# The room share: what a room role may do with a case or matter that is shared with the room.
# Sharing, deleting and ownership never come from a room role. An unknown role gets nothing.
ROOM_RIGHTS = {
"reader": Rights(read=True),
"member": Rights(read=True, edit=True),
"manager": Rights(read=True, edit=True),
}
@dataclass(frozen=True)
class Ctx:
kind: str
@@ -223,6 +240,29 @@ def _exceptions(conn, actor: UUID, kind: str, resource_id: UUID, context: Ctx |
return blocked
def room_default(conn, actor: UUID, resource: dict) -> Rights:
"""Rights of the current room members on a case or matter that is shared with the room.
Only an active room, an active membership and an active account count. The personal
room is never shared. Anything unclear gives no rights.
"""
if resource.get("visibility") != "room":
return Rights()
row = conn.execute(
"""
SELECT m.role
FROM room_memberships m
JOIN data_rooms r ON r.id = m.room_id AND r.kind = 'organization' AND r.status = 'active'
JOIN auth_accounts a ON a.id = m.subject_id AND a.status = 'active'
WHERE m.room_id = %s AND m.subject_id = %s AND m.status = 'active'
""",
(resource["home_scope_id"], actor),
).fetchone()
if row is None:
return Rights()
return ROOM_RIGHTS.get(row["role"], Rights())
def case_rights(conn, actor: UUID, case: dict) -> Rights:
if case["parent_case_id"] is not None and case["rights_mode"] == "inherit_parent":
parent = get_case(conn, case["parent_case_id"])
@@ -230,7 +270,7 @@ def case_rights(conn, actor: UUID, case: dict) -> Rights:
elif case["owner_subject_id"] == actor:
base = Rights.full()
else:
base = _direct_grant(conn, actor, "case", case["id"])
base = _direct_grant(conn, actor, "case", case["id"]).union(room_default(conn, actor, case))
return base.without(_exceptions(conn, actor, "case", case["id"], None))
@@ -244,7 +284,10 @@ def _linked(conn, matter_id: UUID, case_id: UUID) -> bool:
def matter_rights(conn, actor: UUID, matter: dict, context: Ctx | None) -> Rights:
if context is None:
base = Rights.full() if matter["owner_subject_id"] == actor else _direct_grant(conn, actor, "matter", matter["id"])
if matter["owner_subject_id"] == actor:
base = Rights.full()
else:
base = _direct_grant(conn, actor, "matter", matter["id"]).union(room_default(conn, actor, matter))
return base.without(_exceptions(conn, actor, "matter", matter["id"], None))
if context.kind == "case":
@@ -571,6 +614,11 @@ def list_cases(conn, actor: UUID) -> list[dict]:
AND g.grantee_subject_id = %(actor)s AND NOT g.is_exception AND g.can_read
AND g.context_id IS NULL
)
OR (c.visibility = 'room' AND EXISTS (
SELECT 1 FROM room_memberships m
JOIN data_rooms r ON r.id = m.room_id AND r.kind = 'organization' AND r.status = 'active'
WHERE m.room_id = c.home_scope_id AND m.subject_id = %(actor)s AND m.status = 'active'
))
OR (
c.rights_mode = 'inherit_parent' AND c.parent_case_id IS NOT NULL AND EXISTS (
SELECT 1 FROM cases p
@@ -583,6 +631,11 @@ def list_cases(conn, actor: UUID) -> list[dict]:
AND g.grantee_subject_id = %(actor)s AND NOT g.is_exception
AND g.can_read AND g.context_id IS NULL
)
OR (p.visibility = 'room' AND EXISTS (
SELECT 1 FROM room_memberships pm
JOIN data_rooms r ON r.id = pm.room_id AND r.kind = 'organization' AND r.status = 'active'
WHERE pm.room_id = p.home_scope_id AND pm.subject_id = %(actor)s AND pm.status = 'active'
))
)
)
)
@@ -613,6 +666,11 @@ def list_matters(conn, actor: UUID) -> list[tuple[dict, list[dict]]]:
AND g.grantee_subject_id = %(actor)s AND NOT g.is_exception AND g.can_read
AND g.context_id IS NULL
)
OR (m.visibility = 'room' AND EXISTS (
SELECT 1 FROM room_memberships mm
JOIN data_rooms r ON r.id = mm.room_id AND r.kind = 'organization' AND r.status = 'active'
WHERE mm.room_id = m.home_scope_id AND mm.subject_id = %(actor)s AND mm.status = 'active'
))
OR EXISTS (
SELECT 1 FROM matter_case_links l
JOIN cases c ON c.id = l.case_id AND c.deleted_at IS NULL
@@ -625,6 +683,11 @@ def list_matters(conn, actor: UUID) -> list[tuple[dict, list[dict]]]:
AND g.grantee_subject_id = %(actor)s AND NOT g.is_exception
AND g.can_read AND g.context_id IS NULL
)
OR (c.visibility = 'room' AND EXISTS (
SELECT 1 FROM room_memberships cm
JOIN data_rooms r ON r.id = cm.room_id AND r.kind = 'organization' AND r.status = 'active'
WHERE cm.room_id = c.home_scope_id AND cm.subject_id = %(actor)s AND cm.status = 'active'
))
)
)
)