Abuse-Schutz fertig

Dieser Commit ist enthalten in:
Claude Project Manager
2025-11-10 03:09:35 +01:00
Ursprung 52dc7b262a
Commit 14eefa18f6
13 geänderte Dateien mit 553 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -112,6 +112,20 @@ class BasePlatformController(QObject):
Args:
params: Parameter für die Account-Erstellung
"""
# Feature 5: Process Guard - Prüfe ob Prozess starten darf
from utils.process_guard import get_guard
guard = get_guard()
can_start, error_msg = guard.can_start("Account-Erstellung", self.platform_name)
if not can_start:
# Zeige Fehlermeldung
generator_tab = self.get_generator_tab()
generator_tab.show_error(error_msg)
return
# Guard Lock setzen
guard.start("Account-Erstellung", self.platform_name)
self.logger.info(f"Account-Erstellung für {self.platform_name} gestartet")
# In Unterklassen implementieren

Datei anzeigen

@ -48,6 +48,9 @@ class BaseAccountCreationWorkerThread(QThread):
def run(self):
"""Gemeinsame Logik für Account-Erstellung - IDENTISCH zum Original"""
# Feature 5: Tracke Erfolg für Process Guard
success = False
try:
self.update_signal.emit("Status: Initialisierung...")
self.log_signal.emit(f"{self.platform_name}-Account-Erstellung gestartet...")
@ -185,6 +188,9 @@ class BaseAccountCreationWorkerThread(QThread):
if save_result is not None:
result["save_result"] = save_result
# Feature 5: Markiere als erfolgreich für Process Guard
success = True
self.finished_signal.emit(result)
else:
error_msg = result.get("error", "Unbekannter Fehler")
@ -197,11 +203,17 @@ class BaseAccountCreationWorkerThread(QThread):
error_msg = str(e)
self.log_signal.emit(f"Schwerwiegender Fehler: {error_msg}")
self.log_signal.emit(traceback.format_exc())
interpreted_error = self._interpret_error(error_msg)
self.error_signal.emit(interpreted_error)
self.progress_signal.emit(0) # Reset progress on error
finally:
# Feature 5: Process Guard freigeben
from utils.process_guard import get_guard
guard = get_guard()
guard.end(success)
def _interpret_error(self, error_message: str) -> str:
"""Interpretiert Fehler mit Fuzzy-Matching"""
error_lower = error_message.lower()

Datei anzeigen

@ -43,7 +43,7 @@ class SessionController(QObject):
def perform_one_click_login(self, account_data: Dict[str, Any]):
"""
Führt Ein-Klick-Login für einen Account durch.
Args:
account_data: Dict mit Account-Daten inkl. id, platform, username, etc.
"""
@ -51,8 +51,23 @@ class SessionController(QObject):
platform = account_data.get("platform", "")
username = account_data.get("username", "")
logger.info(f"Ein-Klick-Login für Account {username} (ID: {account_id}) auf {platform}")
# Feature 5: Process Guard - Prüfe ob Login starten darf
from utils.process_guard import get_guard
guard = get_guard()
can_start, error_msg = guard.can_start("Account-Login", platform)
if not can_start:
logger.warning(f"Login blockiert durch Guard: {error_msg}")
self.login_failed.emit(account_id, error_msg)
return
# Guard Lock setzen
guard.start("Account-Login", platform)
logger.info(f"Guard locked für Login: {platform}")
self.login_started.emit(account_id)
try:
# Stelle sicher, dass Account einen Fingerprint hat
fingerprint_id = account_data.get("fingerprint_id")
@ -103,19 +118,39 @@ class SessionController(QObject):
else:
error_msg = f"Account mit ID {account_id} nicht gefunden"
logger.error(error_msg)
# Feature 5: Guard freigeben da Worker nicht gestartet wird
guard.end(success=False)
self.login_failed.emit(account_id, error_msg)
except Exception as e:
logger.error(f"Fehler beim Ein-Klick-Login: {e}")
# Feature 5: Guard freigeben bei Fehler vor Worker-Start
guard.end(success=False)
self.login_failed.emit(account_id, str(e))
def _cancel_login(self, account_id: str):
"""Bricht den Login-Prozess ab"""
logger.info(f"Login für Account {account_id} wurde abgebrochen")
# Feature 5: Guard freigeben bei Cancel
# HINWEIS: Worker Thread gibt Guard in seinem finally-Block frei
# Nur freigeben wenn Worker noch nicht gestartet (Guard locked aber kein Worker)
from utils.process_guard import get_guard
guard = get_guard()
if guard.is_locked() and not (hasattr(self, 'login_worker') and self.login_worker and self.login_worker.isRunning()):
logger.warning("Guard war locked aber Worker nicht aktiv - gebe Guard frei")
guard.end(success=False)
if hasattr(self, 'login_dialog') and self.login_dialog:
self.login_dialog.close()
self.login_dialog = None
# TODO: Login-Worker stoppen falls vorhanden
# Login-Worker stoppen falls vorhanden
if hasattr(self, 'login_worker') and self.login_worker:
if self.login_worker.isRunning():
logger.info("Stoppe laufenden Login-Worker")
self.login_worker.terminate()
self.login_worker.wait(2000) # Warte max 2 Sekunden
def create_and_save_account(self, platform: str, account_data: Dict[str, Any]):
"""
@ -220,6 +255,9 @@ class SessionController(QObject):
self.automation = automation # Verwende bereitgestellte Automation oder erstelle neue
def run(self):
# Feature 5: Tracke Erfolg für Process Guard
success = False
try:
# Verwende bereitgestellte Automation oder erstelle neue
if not self.automation:
@ -298,13 +336,22 @@ class SessionController(QObject):
if result['success']:
# Session-Speicherung komplett entfernt - nur Login-Erfolg melden
logger.info(f"Login erfolgreich für Account {self.account_id} - Session-Speicherung deaktiviert")
# Feature 5: Markiere als erfolgreich für Process Guard
success = True
self.login_completed.emit(self.account_id, result)
else:
self.login_failed.emit(self.account_id, result.get('error', 'Login fehlgeschlagen'))
except Exception as e:
logger.error(f"Fehler beim normalen Login: {e}")
self.login_failed.emit(self.account_id, str(e))
finally:
# Feature 5: Process Guard freigeben
from utils.process_guard import get_guard
guard = get_guard()
guard.end(success)
logger.info(f"Guard freigegeben nach Login (success={success})")
def cleanup(self):
"""Browser NICHT schließen - User soll Kontrolle behalten"""