Change email templating to not wrap user defined templates (#3862)
# What this PR does Change email notification templates to not wrap the user template in a fixed body. Info has been moved to a footer. The title now also matches the template from the user exactly and will only get a default message if the user template result is empty. Example:  ## Which issue(s) this PR fixes #3857 ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
160d501bbe
commit
aebd98b8f9
4 changed files with 20 additions and 24 deletions
|
|
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Allow mobile app to access escalation options endpoints @imtoori ([#3847](https://github.com/grafana/oncall/pull/3847))
|
||||
- Enable templating for alert escalation mobile app push notifications by @joeyorlando ([#3845](https://github.com/grafana/oncall/pull/3845))
|
||||
- Change email notification template to not wrap user template @mderynck ([#3862](https://github.com/grafana/oncall/pull/3862))
|
||||
|
||||
## v1.3.102 (2024-02-06)
|
||||
|
||||
|
|
|
|||
|
|
@ -39,17 +39,17 @@ def build_subject_and_message(alert_group, emails_left):
|
|||
content = render_to_string(
|
||||
"email_notification.html",
|
||||
{
|
||||
"url": alert_group.slack_permalink or alert_group.web_link,
|
||||
"title": str_or_backup(templated_alert.title, title_fallback),
|
||||
"message": str_or_backup(message, ""), # not render message at all if smth goes wrong
|
||||
"organization": alert_group.channel.organization.org_title,
|
||||
"integration": emojize(alert_group.channel.short_name, language="alias"),
|
||||
"message": str_or_backup(message, title_fallback),
|
||||
"limit_notification": emails_left <= 20,
|
||||
"emails_left": emails_left,
|
||||
"url": alert_group.slack_permalink or alert_group.web_link,
|
||||
"alert_group_number": str(alert_group.inside_organization_number),
|
||||
"integration": emojize(alert_group.channel.short_name, language="alias"),
|
||||
"instance_url": alert_group.channel.organization.grafana_url,
|
||||
},
|
||||
)
|
||||
|
||||
title = str_or_backup(templated_alert.title, title_fallback)
|
||||
subject = f"[{title}] You are invited to check an alert group".replace("\n", "")
|
||||
subject = f"{title}".replace("\n", "")
|
||||
|
||||
return subject, content
|
||||
|
|
|
|||
|
|
@ -1,28 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
You are invited to check an alert group in Grafana OnCall!
|
||||
<br><br>
|
||||
Organization: {{ organization }}
|
||||
<br>
|
||||
Integration: {{ integration }}
|
||||
<br>
|
||||
Title: {{ title }}
|
||||
{% if message %}
|
||||
<br>
|
||||
Message:
|
||||
<br>
|
||||
{% autoescape off %}
|
||||
{{ message }}
|
||||
{{ message }}
|
||||
{% endautoescape %}
|
||||
{% endif %}
|
||||
<br>
|
||||
<strong><a href="{{ url }}">Go to the alert group</a></strong>
|
||||
<br>
|
||||
Your Grafana OnCall
|
||||
|
||||
{% if limit_notification %}
|
||||
<br><br>
|
||||
<span style="color: #333333;"><em>{{ emails_left }} emails left for the organization today. Contact your admin.</em></span>
|
||||
{% endif %}
|
||||
|
||||
<hr/>
|
||||
<a href="{{ url }}">Alert Group #{{ alert_group_number }}</a> from {{ integration }}
|
||||
<span>|</span>
|
||||
<a href="{{ instance_url }}">{{ instance_url }}</a>
|
||||
<span>|</span>
|
||||
<a href="https://grafana.com/docs/oncall/latest/">Docs</a>
|
||||
<p>
|
||||
- Your <a href="https://grafana.com/products/cloud/oncall/">Grafana OnCall</a>
|
||||
</p>
|
||||
|
||||
<!-- this ensures Gmail doesn't trim the email -->
|
||||
<span style="display:none;">{% now "H:i.u e"%}</span>
|
||||
<!---->
|
||||
|
|
@ -211,4 +211,4 @@ def test_subject_newlines_removed(
|
|||
make_alert(alert_group, raw_request_data={})
|
||||
|
||||
subject, _ = build_subject_and_message(alert_group, 1)
|
||||
assert subject == "[testnewlines] You are invited to check an alert group"
|
||||
assert subject == "testnewlines"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue