Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Remove the per-user diarize leftover (#412 audit S2): Account saves no longer reset it, API v1 reports the active connector default; the column stays for compatibility
Murtaza Nasirce4ebe1c1bec
diff --git a/src/api/api_v1.py b/src/api/api_v1.pyindex ef5f1aa5..abb91390 100644--- a/src/api/api_v1.py+++ b/src/api/api_v1.py@@ -795,7 +795,9 @@ def get_current_user():'show_timestamps_simple_view': bool(current_user.show_timestamps_simple_view),'editor_autosave': bool(current_user.editor_autosave),'notify_email_on_completion': bool(current_user.notify_email_on_completion),- 'diarize': bool(current_user.diarize),+ # The per-user diarize preference has had no control since Aug 2025+ # and was never read; report what transcription actually does.+ 'diarize': _effective_diarize(),},'group_memberships': memberships,})@@ -1473,6 +1475,17 @@ def get_recording_status(recording_id):# Title Regeneration# =============================================================================+def _effective_diarize():+ """Whether recordings are diarized: the active connector's default (the+ processing task passes no per-user preference)."""+ try:+ from src.services.transcription import get_registry+ connector = get_registry().get_active_connector()+ return bool(connector.supports_diarization and connector.default_diarize)+ except Exception:+ return False++@api_v1_bp.route('/recordings/<int:recording_id>/regenerate_title', methods=['POST'])@login_requireddef api_regenerate_title(recording_id):diff --git a/src/api/auth.py b/src/api/auth.pyindex 6fb52e6f..12c1b220 100644--- a/src/api/auth.py+++ b/src/api/auth.py@@ -720,10 +720,6 @@ def account():# Empty string = use the default template (recording_{{id}})current_user.export_filename_template = template_value if template_value else None- # Only update diarize if it's not locked by env var- if 'ASR_DIARIZE' not in os.environ:- current_user.diarize = 'diarize' in request.form-db.session.commit()# Return JSON response for AJAX requests@@ -752,8 +748,6 @@ def account():from src.tasks.processing import _user_title_instructionsdefault_title_prompt_text = _user_title_instructions(None)[0]- asr_diarize_locked = 'ASR_DIARIZE' in os.environ- ASR_DIARIZE = os.environ.get('ASR_DIARIZE', 'false').lower() == 'true'USE_ASR_ENDPOINT = os.environ.get('USE_ASR_ENDPOINT', 'false').lower() == 'true'USE_NEW_TRANSCRIPTION_ARCHITECTURE = os.environ.get('USE_NEW_TRANSCRIPTION_ARCHITECTURE', 'true').lower() == 'true'ENABLE_AUTO_DELETION = os.environ.get('ENABLE_AUTO_DELETION', 'false').lower() == 'true'@@ -841,8 +835,6 @@ def account():enable_auto_deletion=ENABLE_AUTO_DELETION,enable_internal_sharing=ENABLE_INTERNAL_SHARING,user_admin_groups=user_admin_groups,- asr_diarize_locked=asr_diarize_locked,- asr_diarize_env_value=ASR_DIARIZE,is_team_admin=is_team_admin,sso_enabled=sso_enabled,sso_provider_name=sso_config.get('provider_name', 'SSO'),diff --git a/tests/test_diarize_leftover.py b/tests/test_diarize_leftover.pynew file mode 100644index 00000000..f7388576--- /dev/null+++ b/tests/test_diarize_leftover.py@@ -0,0 +1,38 @@+"""The per-user diarize preference is a leftover (#412 audit, item S2).++Its Account-page checkbox was removed in Aug 2025, but the save handler kept+writing the field from the missing checkbox (always False) and API v1 reported+it, while transcription never read it. Saves no longer touch it, and API v1+reports what transcription actually does: the active connector's default.+"""++import os+import re+import sys+from unittest.mock import MagicMock, patch++sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))++from src.app import app+from src.api import api_v1++ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+++def test_account_save_no_longer_writes_the_diarize_field():+ src = open(os.path.join(ROOT, "src", "api", "auth.py"), encoding="utf-8").read()+ assert not re.search(r"current_user\.diarize\s*=", src)+++def test_api_reports_the_connector_default():+ for supports, default, expected in [(True, True, True), (True, False, False), (False, True, False)]:+ connector = MagicMock(supports_diarization=supports, default_diarize=default)+ registry = MagicMock()+ registry.get_active_connector.return_value = connector+ with app.app_context(), patch("src.services.transcription.get_registry", return_value=registry):+ assert api_v1._effective_diarize() is expected+++def test_api_reports_false_when_no_connector_is_available():+ with app.app_context(), patch("src.services.transcription.get_registry", side_effect=RuntimeError("none")):+ assert api_v1._effective_diarize() is False