Mache Datenräume zu Teams, damit Akten und Vorgänge mit beliebigen Räumen geteilt werden können.
Die Raumfreigabe hängt nicht mehr am Heimatraum. Der Owner teilt eine Akte, Unterakte oder einen Vorgang mit jedem Raum, in dem er schreiben darf; die Mitglieder erhalten Rechte nach ihrer Rolle, begrenzbar auf nur lesen, mit Personenausnahme. Ein einzelner Vorgang lässt sich teilen, ohne die Akte oder die anderen Vorgänge offenzulegen. Wer ein Team verlässt oder Leser wird, nimmt seine Freigaben mit; wer entfernt wird, arbeitet danach im persönlichen Raum und sieht weiter alles, was ihm gehört. Der Heimatraum ist nur noch Ablage. Die Migration übernimmt die bisherigen Raumfreigaben in die neue Tabelle room_shares und wurde mit Bestandsdaten geprüft. Die Sitzung meldet einen Raumwechsel jetzt mit eigenem Fehlercode, die Oberfläche lädt sie dann neu. Die lokale Suite läuft mit 132 Tests grün, der Frontend-Build 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:
1 parent
1c2f045e7d
commit
21c2d05fb8
19 files changed
+634
-297
No files matched your search
@@ -240,27 +240,33 @@ 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.
|
||||
def room_default(conn, actor: UUID, kind: str, resource_id: UUID) -> Rights:
|
||||
"""Rights of the current members of the rooms a case or matter is shared with.
|
||||
|
||||
Only an active room, an active membership and an active account count. The personal
|
||||
room is never shared. Anything unclear gives no rights.
|
||||
A room is a team. The rights of one share are the role of the person in that room,
|
||||
capped by the share (`read` or `edit`). Several shares add up. Only an active room,
|
||||
an active membership and an active account count. Anything unclear gives no rights.
|
||||
"""
|
||||
if resource.get("visibility") != "room":
|
||||
return Rights()
|
||||
row = conn.execute(
|
||||
rows = 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'
|
||||
SELECT m.role, s.access
|
||||
FROM room_shares s
|
||||
JOIN room_memberships m ON m.room_id = s.room_id AND m.subject_id = %s AND m.status = 'active'
|
||||
JOIN data_rooms r ON r.id = s.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'
|
||||
WHERE s.resource_kind = %s AND s.resource_id = %s
|
||||
""",
|
||||
(resource["home_scope_id"], actor),
|
||||
).fetchone()
|
||||
if row is None:
|
||||
return Rights()
|
||||
return ROOM_RIGHTS.get(row["role"], Rights())
|
||||
(actor, kind, resource_id),
|
||||
).fetchall()
|
||||
result = Rights()
|
||||
for row in rows:
|
||||
rights = ROOM_RIGHTS.get(row["role"], Rights())
|
||||
if row["access"] == "read":
|
||||
rights = Rights(read=rights.read)
|
||||
elif row["access"] != "edit":
|
||||
rights = Rights()
|
||||
result = result.union(rights)
|
||||
return result
|
||||
|
||||
|
||||
def case_rights(conn, actor: UUID, case: dict) -> Rights:
|
||||
@@ -270,7 +276,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"]).union(room_default(conn, actor, case))
|
||||
base = _direct_grant(conn, actor, "case", case["id"]).union(room_default(conn, actor, "case", case["id"]))
|
||||
return base.without(_exceptions(conn, actor, "case", case["id"], None))
|
||||
|
||||
|
||||
@@ -287,7 +293,7 @@ def matter_rights(conn, actor: UUID, matter: dict, context: Ctx | None) -> Right
|
||||
if matter["owner_subject_id"] == actor:
|
||||
base = Rights.full()
|
||||
else:
|
||||
base = _direct_grant(conn, actor, "matter", matter["id"]).union(room_default(conn, actor, matter))
|
||||
base = _direct_grant(conn, actor, "matter", matter["id"]).union(room_default(conn, actor, "matter", matter["id"]))
|
||||
return base.without(_exceptions(conn, actor, "matter", matter["id"], None))
|
||||
|
||||
if context.kind == "case":
|
||||
@@ -614,10 +620,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 (EXISTS (
|
||||
SELECT 1 FROM room_shares sh
|
||||
JOIN room_memberships sm ON sm.room_id = sh.room_id AND sm.subject_id = %(actor)s AND sm.status = 'active'
|
||||
JOIN data_rooms sr ON sr.id = sh.room_id AND sr.kind = 'organization' AND sr.status = 'active'
|
||||
WHERE sh.resource_kind = 'case' AND sh.resource_id = c.id
|
||||
))
|
||||
OR (
|
||||
c.rights_mode = 'inherit_parent' AND c.parent_case_id IS NOT NULL AND EXISTS (
|
||||
@@ -631,10 +638,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'
|
||||
OR (EXISTS (
|
||||
SELECT 1 FROM room_shares sh
|
||||
JOIN room_memberships sm ON sm.room_id = sh.room_id AND sm.subject_id = %(actor)s AND sm.status = 'active'
|
||||
JOIN data_rooms sr ON sr.id = sh.room_id AND sr.kind = 'organization' AND sr.status = 'active'
|
||||
WHERE sh.resource_kind = 'case' AND sh.resource_id = p.id
|
||||
))
|
||||
)
|
||||
)
|
||||
@@ -666,10 +674,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 room_shares sh
|
||||
JOIN room_memberships sm ON sm.room_id = sh.room_id AND sm.subject_id = %(actor)s AND sm.status = 'active'
|
||||
JOIN data_rooms sr ON sr.id = sh.room_id AND sr.kind = 'organization' AND sr.status = 'active'
|
||||
WHERE sh.resource_kind = 'matter' AND sh.resource_id = m.id
|
||||
))
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM matter_case_links l
|
||||
@@ -683,10 +692,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'
|
||||
OR (EXISTS (
|
||||
SELECT 1 FROM room_shares sh
|
||||
JOIN room_memberships sm ON sm.room_id = sh.room_id AND sm.subject_id = %(actor)s AND sm.status = 'active'
|
||||
JOIN data_rooms sr ON sr.id = sh.room_id AND sr.kind = 'organization' AND sr.status = 'active'
|
||||
WHERE sh.resource_kind = 'case' AND sh.resource_id = c.id
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user