Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 500 on templates when slack or tg integration is disabled #2064

Merged
merged 5 commits into from
May 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove unused function, comments
  • Loading branch information
Konstantinov-Innokentii committed May 31, 2023
commit 9d615abf72bd63e79d82471bc68c80217c07e0a9
27 changes: 4 additions & 23 deletions engine/apps/api/serializers/alert_receive_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,29 +334,6 @@ def to_representation(self, obj):

return ret

def _get_templates_to_show(self, response_data):
"""
For On-prem installations with disabled features it is needed to disable corresponding templates
"""
slack_integration_required_templates = [
"slack_title_template",
"slack_message_template",
"slack_image_url_template",
]
telegram_integration_required_templates = [
"telegram_title_template",
"telegram_message_template",
"telegram_image_url_template",
]
if not settings.FEATURE_SLACK_INTEGRATION_ENABLED:
for st in slack_integration_required_templates:
response_data.pop(st)
if not settings.FEATURE_TELEGRAM_INTEGRATION_ENABLED:
for tt in telegram_integration_required_templates:
response_data.pop(tt)

return response_data

def _get_messaging_backend_templates(self, obj):
"""Return additional messaging backend templates if any."""
templates = {}
Expand Down Expand Up @@ -390,6 +367,10 @@ def _get_core_templates(self, obj):

@property
def core_templates_names(self):
"""
core_templates_names returns names of templates introduced before messaging backends system with respect to
enabled integrations.
"""
core_templates = [
"web_title_template",
"web_message_template",
Expand Down