Compare commits

..

No commits in common. "52873047d647eea1bfc5408b8d3f10fa39005dd3" and "c8a078bc45a36acfa32aebbbb2139bcded1a2349" have entirely different histories.

5 changed files with 11 additions and 48 deletions

View File

@ -1 +1 @@
v20260108-29-inbox-attachment-body-fallback
v20260108-28-admin-all-mail-open-fix

View File

@ -228,15 +228,9 @@ def _store_messages(settings: SystemSettings, messages):
)
# Some systems send empty bodies and put the actual report in an HTML attachment.
# Graph may still return a body that only contains whitespace/newlines; treat that
# as empty so we can fall back to the attachment.
def _is_blank(s):
return s is None or (isinstance(s, str) and s.strip() == "")
# If we have raw EML bytes and no meaningful body content, extract the first
# HTML attachment and use it as the HTML body so parsers and the inbox preview
# can work.
if _is_blank(mail.html_body) and _is_blank(mail.text_body) and mail.eml_blob:
# If we have raw EML bytes and no body content, extract the first HTML attachment
# and use it as the HTML body so parsers and the inbox preview can work.
if not (mail.html_body or mail.text_body) and mail.eml_blob:
attachment_html = extract_best_html_from_eml(mail.eml_blob)
if attachment_html:
mail.html_body = attachment_html

View File

@ -1,8 +1,6 @@
from .routes_shared import * # noqa: F401,F403
from .routes_shared import _format_datetime, _log_admin_event, _send_mail_message_eml_download
from ..email_utils import extract_best_html_from_eml
import time
@main_bp.route("/inbox")
@ -113,24 +111,11 @@ def inbox_message_detail(message_id: int):
),
}
def _is_blank(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)
# For legacy messages: if the Graph body is empty/whitespace but the real report
# is an HTML attachment in the stored EML, extract and render it.
if _is_blank(html_body) and _is_blank(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_blank(html_body):
body_html = html_body
elif not _is_blank(text_body):
if getattr(msg, "html_body", None):
body_html = msg.html_body
elif getattr(msg, "text_body", None):
escaped = (
text_body.replace("&", "&")
msg.text_body.replace("&", "&")
.replace("<", "&lt;")
.replace(">", "&gt;")
)

View File

@ -334,14 +334,6 @@
function wrapMailHtml(html) {
html = html || "";
var trimmed = (typeof html === "string") ? html.trim() : "";
// If the content already looks like a full HTML document (common for report attachments),
// do not wrap it again.
if (trimmed.toLowerCase().indexOf("<!doctype") === 0 || trimmed.toLowerCase().indexOf("<html") === 0) {
return trimmed;
}
// Ensure we render the mail HTML with its own CSS, isolated from the site styling.
return (
"<!doctype html><html><head><meta charset=\"utf-8\">" +

View File

@ -16,18 +16,10 @@
---
## v20260108-28-admin-all-mail-popup-fix
## v20260108-28-admin-all-mail-open-fix
- Fixed All Mail row-click handling by switching to event delegation, ensuring message rows reliably open the detail modal.
- Ensured EML link clicks no longer trigger row-click modal opening.
- Fixed mail popup opening in the Admin All Mail audit page.
- Aligned click and modal handling with the Inbox implementation to ensure messages can be opened correctly.
- No functional changes to search, filtering, pagination, or permissions.
---
## v20260108-29-inbox-attachment-body-fallback
- Treat whitespace-only email bodies as empty during import, so HTML report attachments can be extracted from stored EML and shown as the message body.
- Add legacy fallback in the Inbox message detail API: when stored bodies are empty/whitespace, extract the first HTML attachment from EML and render it.
- Improve Inbox iframe rendering: if the returned content is a full HTML document (common for report attachments), render it directly instead of wrapping it.
================================================================================================================================================
## v0.1.18