diff --git a/felicity/apps/abstract/events.py b/felicity/apps/abstract/events.py index 085566c9..5513c082 100644 --- a/felicity/apps/abstract/events.py +++ b/felicity/apps/abstract/events.py @@ -7,7 +7,7 @@ logger = logging.getLogger(__name__) def change_tracker(action: str, table_name: str, metadata): - logger.info(f"Event fired: {action}:{table_name}") + # logger.info(f"Event fired: {action}:{table_name} --> NotUsed") if not metadata: return @@ -17,6 +17,7 @@ def change_tracker(action: str, table_name: str, metadata): **metadata.get("state_after") } + # Hook thinks like meilisearch here etc # SomeHandler().on_event(action, table_name, metadata) diff --git a/felicity/apps/auditlog/events.py b/felicity/apps/auditlog/events.py index 747e27ce..90967624 100644 --- a/felicity/apps/auditlog/events.py +++ b/felicity/apps/auditlog/events.py @@ -10,6 +10,9 @@ logger = logging.getLogger(__name__) async def auditlog_tracker(action: str, table_name: str, metadata): + if settings.AUDITABLE_ENTITIES and table_name not in settings.AUDITABLE_ENTITIES: + return + if action != "after-update" and not metadata: return @@ -19,7 +22,7 @@ async def auditlog_tracker(action: str, table_name: str, metadata): if metadata["state_after"] == metadata["state_before"]: return - logger.info(f"Event fired: {action}:{table_name}") + logger.info(f"Event fired: {action}:{table_name} --> AuditLogEntry") update = { **metadata, "user_uid": metadata["state_after"].get("updated_by_uid", None), diff --git a/felicity/core/config.py b/felicity/core/config.py index a7086618..e222eddf 100644 --- a/felicity/core/config.py +++ b/felicity/core/config.py @@ -138,7 +138,10 @@ class Settings(BaseSettings): DOCUMENT_STORAGE: bool = bool(MONGODB_SERVER) and bool(MONGODB_USER) and bool(MONGODB_PASS) # Use external storage for objects/blobs OBJECT_STORAGE: bool = bool(MINIO_SERVER) and bool(MINIO_ACCESS) and bool(MINIO_SECRET) - + # Limit Tables for audit-log: if empty, all will be audited + AUDITABLE_ENTITIES: list[str] = [ + "sample", "analysis_result", "test_bill", "client", "patient" + ] model_config = SettingsConfigDict( env_file=ENV_FILE, env_file_encoding="utf-8",