Files
Juan Denis 6296887bad Remove internal plan citations from app code
Comments, docstrings and a few strings cited plan numbers ("plan 29
#9", "plan 86 §B2") from a git-ignored folder, so they pointed at
nothing; one reached users in a bottleneck hint. Code and frontend
strings are unchanged apart from those citations (checked by AST and
token comparison). A vhost still carrying the old asset comment reads
as undrifted, and a guard test keeps new citations out.
2026-10-10 15:50:45 -04:00

42 lines
1.5 KiB
Python

"""Deep-link helpers for notifications.
A notification's ``action_path`` is stored relative (e.g. ``/domains``) so a
route move never breaks old rows. For channels that need an absolute URL (email,
chat) we resolve it against the panel's canonical domain at render time.
"""
import logging
logger = logging.getLogger(__name__)
def panel_base_url():
"""Absolute base URL of the panel, or '' when no canonical domain is set."""
try:
from app.services.settings_service import SettingsService
domain = (SettingsService.get('canonical_domain', '') or '').strip()
if not domain:
return ''
scheme = 'https' if SettingsService.get('canonical_https_enabled', False) else 'http'
return f'{scheme}://{domain}'
except Exception: # pragma: no cover - settings unavailable
return ''
def absolute_url(path):
"""Turn an ``action_path`` into an absolute URL. Returns None for a falsy
path; returns the path unchanged if already absolute or if no base is set."""
if not path:
return None
if path.startswith('http://') or path.startswith('https://'):
return path
base = panel_base_url()
if not base:
return path # relative fallback — the in-app bell is the primary surface
return base.rstrip('/') + '/' + path.lstrip('/')
def manage_url():
"""The 'manage notifications' footer link, absolute when possible."""
resolved = absolute_url('/settings/notifications')
return resolved if (resolved and resolved.startswith('http')) else None