stages/email: Only attach logo to email if used (#14835) * Only attach logo to email if used * Fix MIME logo attachment to adhere to standard * format, fix web * not tuple --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Christian Elsen <chriselsen@users.noreply.github.com> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
committed by
GitHub
parent
2be5c9633b
commit
b94fb53821
@ -100,8 +100,10 @@ def send_mail(
|
|||||||
# Because we use the Message-ID as UID for the task, manually assign it
|
# Because we use the Message-ID as UID for the task, manually assign it
|
||||||
message_object.extra_headers["Message-ID"] = message_id
|
message_object.extra_headers["Message-ID"] = message_id
|
||||||
|
|
||||||
# Add the logo (we can't add it in the previous message since MIMEImage
|
# Add the logo if it is used in the email body (we can't add it in the
|
||||||
# can't be converted to json)
|
# previous message since MIMEImage can't be converted to json)
|
||||||
|
body = get_email_body(message_object)
|
||||||
|
if "cid:logo" in body:
|
||||||
message_object.attach(logo_data())
|
message_object.attach(logo_data())
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -96,7 +96,7 @@
|
|||||||
<table width="100%" style="background-color: #FFFFFF; border-spacing: 0; margin-top: 15px;">
|
<table width="100%" style="background-color: #FFFFFF; border-spacing: 0; margin-top: 15px;">
|
||||||
<tr height="80">
|
<tr height="80">
|
||||||
<td align="center" style="padding: 20px 0;">
|
<td align="center" style="padding: 20px 0;">
|
||||||
<img src="{% block logo_url %}cid:logo.png{% endblock %}" border="0=" alt="authentik logo" class="flexibleImage logo">
|
<img src="{% block logo_url %}cid:logo{% endblock %}" border="0=" alt="authentik logo" class="flexibleImage logo">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@ -19,7 +19,8 @@ def logo_data() -> MIMEImage:
|
|||||||
path = Path("web/dist/assets/icons/icon_left_brand.png")
|
path = Path("web/dist/assets/icons/icon_left_brand.png")
|
||||||
with open(path, "rb") as _logo_file:
|
with open(path, "rb") as _logo_file:
|
||||||
logo = MIMEImage(_logo_file.read())
|
logo = MIMEImage(_logo_file.read())
|
||||||
logo.add_header("Content-ID", "logo.png")
|
logo.add_header("Content-ID", "<logo>")
|
||||||
|
logo.add_header("Content-Disposition", "inline", filename="logo.png")
|
||||||
return logo
|
return logo
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -374,7 +374,7 @@ ${JSON.stringify(value.new_value, null, 4)}</pre
|
|||||||
|
|
||||||
renderEmailSent() {
|
renderEmailSent() {
|
||||||
let body = this.event.context.body as string;
|
let body = this.event.context.body as string;
|
||||||
body = body.replace("cid:logo.png", "/static/dist/assets/icons/icon_left_brand.png");
|
body = body.replace("cid:logo", "/static/dist/assets/icons/icon_left_brand.png");
|
||||||
return html`<div class="pf-c-card__title">${msg("Email info:")}</div>
|
return html`<div class="pf-c-card__title">${msg("Email info:")}</div>
|
||||||
<div class="pf-c-card__body">${this.getEmailInfo(this.event.context)}</div>
|
<div class="pf-c-card__body">${this.getEmailInfo(this.event.context)}</div>
|
||||||
<ak-expand>
|
<ak-expand>
|
||||||
|
|||||||
Reference in New Issue
Block a user