From 1cbec82d651f6d7070c077d743f0f00580d632c0 Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Thu, 8 Jan 2026 15:10:32 +0100 Subject: [PATCH] Auto-commit local changes before build (2026-01-08 15:10:32) --- .last-branch | 2 +- .../src/backend/app/main/routes_run_checks.py | 26 ++++++++++++++++++- docs/changelog.md | 7 +++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/.last-branch b/.last-branch index 88e898b..5a4f9e9 100644 --- a/.last-branch +++ b/.last-branch @@ -1 +1 @@ -v20260108-33-runchecks-success-override +v20260108-34-runchecks-popup-mail-body diff --git a/containers/backupchecks/src/backend/app/main/routes_run_checks.py b/containers/backupchecks/src/backend/app/main/routes_run_checks.py index 0263157..52f023e 100644 --- a/containers/backupchecks/src/backend/app/main/routes_run_checks.py +++ b/containers/backupchecks/src/backend/app/main/routes_run_checks.py @@ -22,6 +22,7 @@ from .routes_shared import ( get_active_role, ) from ..database import db +from ..email_utils import extract_best_html_from_eml, is_effectively_blank_html from ..models import ( Customer, Job, @@ -618,7 +619,30 @@ def run_checks_details(): "subject": msg.subject or "", "received_at": _format_datetime(msg.received_at), } - body_html = msg.html_body or "" + def _is_blank_text(s): + return s is None or (isinstance(s, str) and s.strip() == "") + + html_body = getattr(msg, "html_body", None) + text_body = getattr(msg, "text_body", None) + + # Keep Run Checks consistent with Inbox/All Mail: if the Graph body is empty but the + # real report is stored as an HTML attachment inside the EML, extract it. + if is_effectively_blank_html(html_body) and _is_blank_text(text_body) and getattr(msg, "eml_blob", None): + extracted = extract_best_html_from_eml(getattr(msg, "eml_blob", None)) + if extracted: + html_body = extracted + + if not is_effectively_blank_html(html_body): + body_html = html_body + elif not _is_blank_text(text_body): + escaped = ( + text_body.replace("&", "&") + .replace("<", "<") + .replace(">", ">") + ) + body_html = f"
{escaped}
" + else: + body_html = "

No message content stored.

" has_eml = bool(getattr(msg, "eml_stored_at", None)) objects_payload = [] diff --git a/docs/changelog.md b/docs/changelog.md index 9dbc301..f4ca00c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -63,6 +63,13 @@ - Updated UI logic so overridden runs are displayed with the blue success indicator. - Ensured the override only affects the selected run and does not modify original run data. +--- + +## v20260108-34-runchecks-popup-mail-body +- Fixed Run Checks modal mail rendering by falling back to text_body when html_body is empty, matching Inbox/All Mail behavior. +- Added support to extract HTML content from stored EML when both html_body and text_body are blank (consistent with Inbox). +- Updated Run Checks details API to return a safe HTML body for plain-text emails using
 wrapping.
+
 ================================================================================================================================================
 ## v0.1.18