Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Fix news subscription system issues and CSP errors

LearningCircuit6f5c6d3b5249
diff --git a/src/local_deep_research/api/__init__.py b/src/local_deep_research/api/__init__.py
index a50441531d..37cee2150f 100644
--- a/src/local_deep_research/api/__init__.py
+++ b/src/local_deep_research/api/__init__.py
@@ -18,7 +18,6 @@ from .settings_utils import (
from ..news import (
get_news_feed,
research_news_item,
- submit_news_feedback,
save_news_preferences,
get_news_categories,
)
@@ -33,7 +32,6 @@ __all__ = [
"extract_setting_value",
"get_news_feed",
"research_news_item",
- "submit_news_feedback",
"save_news_preferences",
"get_news_categories",
]
diff --git a/src/local_deep_research/config/paths.py b/src/local_deep_research/config/paths.py
index 699b57cd53..877d031092 100644
--- a/src/local_deep_research/config/paths.py
+++ b/src/local_deep_research/config/paths.py
@@ -115,6 +115,18 @@ def get_database_path() -> Path:
)
+def get_encrypted_database_path() -> Path:
+ """Get the path to the encrypted databases directory.
+
+ Returns:
+ Path to the encrypted databases directory
+ """
+ data_dir = get_data_directory()
+ encrypted_db_path = data_dir / "encrypted_databases"
+ encrypted_db_path.mkdir(parents=True, exist_ok=True)
+ return encrypted_db_path
+
+
def get_user_database_filename(username: str) -> str:
"""Get the database filename for a specific user.
diff --git a/src/local_deep_research/news/__init__.py b/src/local_deep_research/news/__init__.py
index b07c5f20d9..cc62757d31 100644
--- a/src/local_deep_research/news/__init__.py
+++ b/src/local_deep_research/news/__init__.py
@@ -13,6 +13,14 @@ from .subscription_manager.scheduler import NewsScheduler, get_news_scheduler
from .folder_manager import FolderManager
from .subscription_manager import SearchSubscription, TopicSubscription
+# Import API functions
+from .api import (
+ get_news_feed,
+ research_news_item,
+ save_news_preferences,
+ get_news_categories,
+)
+
__all__ = [
# Core classes
"BaseSubscription",
@@ -24,4 +32,9 @@ __all__ = [
"FolderManager",
"SearchSubscription",
"TopicSubscription",
+ # API functions
+ "get_news_feed",
+ "research_news_item",
+ "save_news_preferences",
+ "get_news_categories",
]
diff --git a/src/local_deep_research/news/api.py b/src/local_deep_research/news/api.py
index add2fa1289..456f15d4fc 100644
--- a/src/local_deep_research/news/api.py
+++ b/src/local_deep_research/news/api.py
@@ -557,7 +557,6 @@ def get_subscription_history(
# Convert to dict for response
subscription_dict = {
"id": subscription.id,
- "user_id": subscription.user_id,
"query_or_topic": subscription.query_or_topic,
"subscription_type": subscription.subscription_type,
"refresh_interval_minutes": subscription.refresh_interval_minutes,
diff --git a/src/local_deep_research/news/flask_api.py b/src/local_deep_research/news/flask_api.py
index 96945dafec..b1d7171bef 100644
--- a/src/local_deep_research/news/flask_api.py
+++ b/src/local_deep_research/news/flask_api.py
@@ -562,6 +562,7 @@ def get_scheduler_status() -> Dict[str, Any]:
# Build status manually to avoid potential deadlock
status = {
+ "scheduler_available": True, # APScheduler is installed and working
"is_running": scheduler.is_running,
"config": scheduler.config.copy()
if hasattr(scheduler, "config")
diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.py
index 84d82e20e5..8ffe19eec2 100644
--- a/src/local_deep_research/web/app_factory.py
+++ b/src/local_deep_research/web/app_factory.py
@@ -180,8 +180,8 @@ def create_app():
"News module disabled - subscription scheduler not started"
)
app.news_scheduler = None
- except Exception as e:
- logger.exception(f"Failed to initialize news scheduler: {e}")
+ except Exception:
+ logger.exception("Failed to initialize news scheduler")
app.news_scheduler = None
# Apply middleware
@@ -265,8 +265,8 @@ def apply_middleware(app):
"default-src 'self'; "
"connect-src 'self' ws: wss: http: https:; "
"script-src 'self' 'unsafe-inline' 'unsafe-eval' cdnjs.cloudflare.com cdn.jsdelivr.net unpkg.com; "
- "style-src 'self' 'unsafe-inline' cdnjs.cloudflare.com; "
- "font-src 'self' cdnjs.cloudflare.com; "
+ "style-src 'self' 'unsafe-inline' cdnjs.cloudflare.com cdn.jsdelivr.net; "
+ "font-src 'self' cdnjs.cloudflare.com cdn.jsdelivr.net; "
"img-src 'self' data:; "
"worker-src blob:; "
"frame-src 'self';"
@@ -345,9 +345,9 @@ def register_blueprints(app):
except ImportError as e:
news_available = False
logger.warning(f"News module not available: {e}")
- except Exception as e:
+ except Exception:
news_available = False
- logger.exception(f"Error importing news module: {e}")
+ logger.exception("Error importing news module")
# Add root route
@app.route("/")
@@ -406,8 +406,8 @@ def register_blueprints(app):
news_bp = create_news_blueprint()
app.register_blueprint(news_bp, url_prefix="/news")
logger.info("News blueprint registered successfully")
- except Exception as e:
- logger.exception(f"Failed to register news blueprint: {e}")
+ except Exception:
+ logger.exception("Failed to register news blueprint")
news_available = False
# Register API v1 blueprint
diff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.py
index 35290f37dd..465dfe8643 100644
--- a/src/local_deep_research/web/routes/settings_routes.py
+++ b/src/local_deep_research/web/routes/settings_routes.py
@@ -18,7 +18,7 @@ from flask import (
from flask_wtf.csrf import generate_csrf
from loguru import logger
-from ...config.paths import get_data_directory, get_database_path
+from ...config.paths import get_data_directory, get_encrypted_database_path
from ...database.models import Setting, SettingType
from ...database.session_context import get_user_db_session
from ...database.encrypted_db import db_manager
@@ -559,8 +559,8 @@ def save_settings():
failed_count += 1
logger.warning(f"Failed to save setting {key}")
- except Exception as e:
- logger.exception(f"Error saving setting {key}: {e}")
+ except Exception:
+ logger.exception(f"Error saving setting {key}")
failed_count += 1
# Commit all changes at once
@@ -578,9 +578,9 @@ def save_settings():
"warning",
)
- except Exception as e:
+ except Exception:
db_session.rollback()
- logger.exception(f"Failed to commit settings: {e}")
+ logger.exception("Failed to commit settings")
flash("Error saving settings. Please try again.", "error")
return redirect(url_for("settings.settings_page"))
@@ -2114,7 +2114,8 @@ def api_get_data_location():
try:
# Get the data directory path
data_dir = get_data_directory()
- db_path = get_database_path()
+ # Get the encrypted databases path
+ encrypted_db_path = get_encrypted_database_path()
# Check if LDR_DATA_DIR environment variable is set
custom_data_dir = os.environ.get("LDR_DATA_DIR", None)
@@ -2134,6 +2135,12 @@ def api_get_data_location():
# Get SQLCipher settings from environment
from ...database.sqlcipher_utils import get_sqlcipher_settings
+ # Debug logging
+ logger.info(f"db_manager type: {type(db_manager)}")
+ logger.info(
+ f"db_manager.has_encryption: {getattr(db_manager, 'has_encryption', 'ATTRIBUTE NOT FOUND')}"
+ )
+
cipher_settings = (
get_sqlcipher_settings() if db_manager.has_encryption else {}
)
@@ -2141,7 +2148,8 @@ def api_get_data_location():
return jsonify(
{
"data_directory": str(data_dir),
- "database_path": str(db_path),
+ "database_path": str(encrypted_db_path),
+ "encrypted_database_path": str(encrypted_db_path),
"is_custom": custom_data_dir is not None,
"custom_env_var": "LDR_DATA_DIR",
"custom_env_value": custom_data_dir,
diff --git a/src/local_deep_research/web/templates/base.html b/src/local_deep_research/web/templates/base.html
index f6aa969e1c..5088c0a7de 100644
--- a/src/local_deep_research/web/templates/base.html
+++ b/src/local_deep_research/web/templates/base.html
@@ -48,15 +48,17 @@
{% block templates %}{% endblock %}
<!-- Scripts -->
+
+ <!-- URL Configuration (must load first) -->
+ <script src="{{ url_for('research.serve_static', path='js/config/urls.js') }}"></script>
+
+ <!-- External Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js" integrity="sha512-iqRVtNB+t9O+epcgUTIPF+nklypcR23H1yR1NFM9kffn6/iBhZ9bTB6oKLaGMv8JE9UgjcwfBFg/eHC/VMws+g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/marked.umd.min.js" integrity="sha512-P0TPTfSkSA7/I3P0xjPz+qIrXojG8vEAU2EfFkaYFX7tdN1yeMM4ryUfuHHMKOugMpb+0bgYAmDl+2aN7Bogpg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js" integrity="sha512-bgHRAiTjGrzHzLyKOnpFvaEpGzJet3z4tZnXGjpsCcqOnAH6VGUx9frc5bcIhKTVLEiCO6vEhNAgx5jtLUYrfA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js" integrity="sha512-qZvrmS2ekKPF2mSznTQsxqPgnpkI4DNTlrdUmTzrDgektczlKNRRhy5X5AAOnx5S09ydFYWWNSfcEqDTTHgtNA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js" integrity="sha512-BNaRQnYJYiPSqHHDb58B0yaPfCu+Wgds8Gp/gU33kqBtgNS4tSPHuGibyoeqMV/TJlSKda6FXzoEyYGjTe+vXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
- <!-- URL Configuration (must load first) -->
- <script src="{{ url_for('research.serve_static', path='js/config/urls.js') }}"></script>
-
<!-- Core JS -->
<script src="{{ url_for('research.serve_static', path='js/services/formatting.js') }}"></script>
<script src="{{ url_for('research.serve_static', path='js/services/ui.js') }}"></script>
diff --git a/src/local_deep_research/web/templates/pages/subscriptions.html b/src/local_deep_research/web/templates/pages/subscriptions.html
index 1a518fc6d7..bd63d2e626 100644
--- a/src/local_deep_research/web/templates/pages/subscriptions.html
+++ b/src/local_deep_research/web/templates/pages/subscriptions.html
@@ -59,9 +59,9 @@
<a href="/news" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left"></i> Back to News Feed
</a>
- <a href="/news/subscriptions/new" class="btn btn-primary">
- <i class="bi bi-plus-circle"></i> New Subscription
- </a>
+ <button id="create-subscription-btn" class="btn btn-primary">
+ <i class="bi bi-plus-circle"></i> Create Subscription
+ </button>
</div>
</div>