Quellcode durchsuchen

fix: update placeholder for sensitive fields in save_config function

Manuel vor 6 Monaten
Ursprung
Commit
a6258a7d1c
1 geänderte Dateien mit 3 neuen und 2 gelöschten Zeilen
  1. 3 2
      services/notifications/telegram_config_service.py

+ 3 - 2
services/notifications/telegram_config_service.py

@@ -22,6 +22,7 @@ from database.database import get_session
 from database.models.models import TelegramConfig
 
 _SENSITIVE_FIELDS = ("api_hash", "bot_token")
+_SECRET_PLACEHOLDER = "".join(chr(8226) for _ in range(8))
 
 
 def _default_config() -> dict:
@@ -141,11 +142,11 @@ def save_config(data: dict) -> None:
         # Encrypt sensitive fields only when a non-empty value is provided.
         # An empty string means "leave unchanged" (placeholder masking in the UI).
         new_api_hash = str(data.get("api_hash") or "").strip()
-        if new_api_hash and new_api_hash != "••••••••":
+        if new_api_hash and new_api_hash != _SECRET_PLACEHOLDER:
             row.api_hash = _encrypt(new_api_hash, row.encryption_key)
 
         new_bot_token = str(data.get("bot_token") or "").strip()
-        if new_bot_token and new_bot_token != "••••••••":
+        if new_bot_token and new_bot_token != _SECRET_PLACEHOLDER:
             row.bot_token = _encrypt(new_bot_token, row.encryption_key)
 
         session.commit()