Merge pull request 'Auto-commit local changes before build (2026-01-08 13:47:59)' (#64) from v20260108-29-inbox-attachment-body-fallback into main
Reviewed-on: #64
This commit is contained in:
commit
52873047d6
@ -1 +1 @@
|
||||
v20260108-28-admin-all-mail-open-fix
|
||||
v20260108-29-inbox-attachment-body-fallback
|
||||
|
||||
@ -228,9 +228,15 @@ def _store_messages(settings: SystemSettings, messages):
|
||||
)
|
||||
|
||||
# Some systems send empty bodies and put the actual report in an HTML attachment.
|
||||
# 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:
|
||||
# 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:
|
||||
attachment_html = extract_best_html_from_eml(mail.eml_blob)
|
||||
if attachment_html:
|
||||
mail.html_body = attachment_html
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
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")
|
||||
@ -111,11 +113,24 @@ def inbox_message_detail(message_id: int):
|
||||
),
|
||||
}
|
||||
|
||||
if getattr(msg, "html_body", None):
|
||||
body_html = msg.html_body
|
||||
elif getattr(msg, "text_body", None):
|
||||
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):
|
||||
escaped = (
|
||||
msg.text_body.replace("&", "&")
|
||||
text_body.replace("&", "&")
|
||||
.replace("<", "<")
|
||||
.replace(">", ">")
|
||||
)
|
||||
|
||||
@ -334,6 +334,14 @@
|
||||
|
||||
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\">" +
|
||||
|
||||
@ -16,10 +16,18 @@
|
||||
|
||||
---
|
||||
|
||||
## 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.
|
||||
## v20260108-28-admin-all-mail-popup-fix
|
||||
|
||||
- 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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user