events: improve information sent in notification emails
This commit is contained in:
parent
580d59e921
commit
1f8130e685
|
@ -272,17 +272,24 @@ class NotificationTransport(models.Model):
|
||||||
|
|
||||||
def send_email(self, notification: "Notification") -> list[str]:
|
def send_email(self, notification: "Notification") -> list[str]:
|
||||||
"""Send notification via global email configuration"""
|
"""Send notification via global email configuration"""
|
||||||
body_trunc = (
|
subject = "authentik Notification: "
|
||||||
(notification.body[:75] + "..")
|
key_value = {}
|
||||||
if len(notification.body) > 75
|
if notification.event:
|
||||||
else notification.body
|
subject += notification.event.action
|
||||||
)
|
for key, value in notification.event.context.items():
|
||||||
|
if not isinstance(value, str):
|
||||||
|
continue
|
||||||
|
key_value[key] = value
|
||||||
|
else:
|
||||||
|
subject += notification.body[:75]
|
||||||
mail = TemplateEmailMessage(
|
mail = TemplateEmailMessage(
|
||||||
subject=f"authentik Notification: {body_trunc}",
|
subject=subject,
|
||||||
template_name="email/generic.html",
|
template_name="email/generic.html",
|
||||||
to=[notification.user.email],
|
to=[notification.user.email],
|
||||||
template_context={
|
template_context={
|
||||||
|
"title": subject,
|
||||||
"body": notification.body,
|
"body": notification.body,
|
||||||
|
"key_value": key_value,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
# Email is sent directly here, as the call to send() should have been from a task.
|
# Email is sent directly here, as the call to send() should have been from a task.
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{% extends "email/base.html" %}
|
{% extends "email/base.html" %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="alert alert-brand">
|
<td class="alert alert-brand">
|
||||||
|
@ -14,6 +16,29 @@
|
||||||
{{ body }}
|
{{ body }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% if key_value %}
|
||||||
|
<tr>
|
||||||
|
<td class="content-block aligncenter">
|
||||||
|
<table class="invoice">
|
||||||
|
<tr>
|
||||||
|
<td>{% trans "Additional Information" %}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<table class="invoice-items" cellpadding="0" cellspacing="0">
|
||||||
|
{% for key, value in key_value.items %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ key }}</td>
|
||||||
|
<td class="alignright">{{ value }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { gettext } from "django";
|
||||||
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||||
import { Event } from "../../api/Events";
|
import { Event } from "../../api/Events";
|
||||||
import { COMMON_STYLES } from "../../common/styles";
|
import { COMMON_STYLES } from "../../common/styles";
|
||||||
|
import "./EventInfo";
|
||||||
|
|
||||||
@customElement("ak-event-info-page")
|
@customElement("ak-event-info-page")
|
||||||
export class EventInfoPage extends LitElement {
|
export class EventInfoPage extends LitElement {
|
||||||
|
|
Reference in New Issue