Load bounded recovery predicate only for recovery presentation

This commit is contained in:
martino
2026-10-01 08:38:32 +02:00
parent 3be15211b1
commit 54eef11334
+11 -9
View File
@@ -2070,12 +2070,13 @@ def render_template(event_type: str, data: Dict[str, Any],
return '' return ''
safe_vars = _SafeDict(variables) safe_vars = _SafeDict(variables)
from health_recovery import presents_recovery if event_type == 'error_resolved':
if event_type == 'error_resolved' and presents_recovery(data): from health_recovery import presents_recovery
safe_vars['_health_title'] = runtime_message('healthRecovery.title', language, **variables) if presents_recovery(data):
safe_vars['_health_body'] = runtime_message('healthRecovery.body', language, **variables) safe_vars['_health_title'] = runtime_message('healthRecovery.title', language, **variables)
template['title'] = '{_health_title}' safe_vars['_health_body'] = runtime_message('healthRecovery.body', language, **variables)
template['body'] = '{_health_body}' template['title'] = '{_health_title}'
template['body'] = '{_health_body}'
try: try:
title = template['title'].format_map(safe_vars) title = template['title'].format_map(safe_vars)
except (ValueError, IndexError): except (ValueError, IndexError):
@@ -2532,9 +2533,10 @@ def enrich_with_emojis(event_type: str, title: str, body: str,
severity = data.get('severity', 'INFO') severity = data.get('severity', 'INFO')
icon = EVENT_EMOJI.get(event_type) or CATEGORY_EMOJI.get(group) or SEVERITY_ICONS.get(severity, '') icon = EVENT_EMOJI.get(event_type) or CATEGORY_EMOJI.get(group) or SEVERITY_ICONS.get(severity, '')
from health_recovery import presents_recovery if event_type == 'error_resolved':
if event_type == 'error_resolved' and presents_recovery(data): from health_recovery import presents_recovery
icon = '✅' if presents_recovery(data):
icon = '✅'
if event_type == 'backup_complete': if event_type == 'backup_complete':
icon = { icon = {
'confirmed': '💾✅', 'completed_with_warnings': '💾⚠️', 'failed': '💾❌', 'confirmed': '💾✅', 'completed_with_warnings': '💾⚠️', 'failed': '💾❌',