forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount_deletion_projection_fence.py
More file actions
43 lines (33 loc) · 1.42 KB
/
Copy pathaccount_deletion_projection_fence.py
File metadata and controls
43 lines (33 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Durable account-deletion fence for external memory projections."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Dict, cast
from database.account_deletion_policy import account_deletion_blocks_access, normalize_account_deletion_status
ACCOUNT_DELETION_COLLECTION = "account_deletions"
@dataclass(frozen=True)
class AccountDeletionProjectionFence:
status: str | None
blocks_projection_writes: bool
def read_account_deletion_projection_fence(
uid: str,
*,
db_client: Any,
) -> AccountDeletionProjectionFence:
"""Read the top-level deletion authority that survives the user-data wipe."""
if not uid.strip():
raise ValueError("uid is required")
snapshot = db_client.document(f"{ACCOUNT_DELETION_COLLECTION}/{uid}").get()
if not getattr(snapshot, "exists", False):
return AccountDeletionProjectionFence(status=None, blocks_projection_writes=False)
raw: object = snapshot.to_dict()
payload = cast(Dict[str, Any], raw) if isinstance(raw, dict) else {}
status = normalize_account_deletion_status(marker_exists=True, raw_status=payload.get("wipe_status"))
return AccountDeletionProjectionFence(
status=status,
blocks_projection_writes=account_deletion_blocks_access(status),
)
__all__ = [
"ACCOUNT_DELETION_COLLECTION",
"AccountDeletionProjectionFence",
"read_account_deletion_projection_fence",
]