Merge branch 'iskhakov/mobile-app-fixes' of https://github.com/grafana/oncall into iskhakov/mobile-app-fixes

This commit is contained in:
Ildar Iskhakov 2022-07-20 10:59:38 +03:00
commit c25ced2562

View file

@ -1,7 +1,4 @@
import re
from apps.alerts.incident_appearance.templaters.alert_templater import AlertTemplater
from common.utils import escape_html, url_re
class AlertClassicMarkdownTemplater(AlertTemplater):
@ -11,20 +8,13 @@ class AlertClassicMarkdownTemplater(AlertTemplater):
return self.RENDER_FOR
def _postformat(self, templated_alert):
link_substitution = {}
if templated_alert.title:
templated_alert.title = escape_html(self._slack_format_for_web(templated_alert.title))
templated_alert.title = self._slack_format(templated_alert.title)
if templated_alert.message:
message = escape_html(self._slack_format_for_web(templated_alert.message))
link_matches = re.findall(url_re, message)
for idx, link in enumerate(link_matches):
substitution = f"amixrsubstitutedlink{idx}"
link_substitution[substitution] = link
message = message.replace(link, substitution)
templated_alert.message = self._slack_format(templated_alert.message)
return templated_alert
def _slack_format_for_web(self, data):
def _slack_format(self, data):
sf = self.slack_formatter
sf.hyperlink_mention_format = "[{title}]({url})"
return sf.format(data)