diff --git a/engine/apps/api/serializers/organization.py b/engine/apps/api/serializers/organization.py index 523f6825..6279c0a1 100644 --- a/engine/apps/api/serializers/organization.py +++ b/engine/apps/api/serializers/organization.py @@ -131,7 +131,10 @@ class CurrentOrganizationConfigChecksSerializer(serializers.ModelSerializer): def get_is_integration_chatops_connected(self, obj): return ( - obj.alert_receive_channels.filter(channel_filters__notify_in_slack=True).exists() + ( + obj.slack_team_identity_id is not None + and obj.alert_receive_channels.filter(channel_filters__notify_in_slack=True).exists() + ) or obj.alert_receive_channels.filter(channel_filters__notify_in_telegram=True).exists() or obj.alert_receive_channels.filter(channel_filters__notification_backends__MSTEAMS__enabled=True).exists() ) diff --git a/engine/apps/api/tests/test_organization.py b/engine/apps/api/tests/test_organization.py index a4eceec0..4d04d6c1 100644 --- a/engine/apps/api/tests/test_organization.py +++ b/engine/apps/api/tests/test_organization.py @@ -269,8 +269,17 @@ def test_get_organization_slack_config_checks( assert response.status_code == status.HTTP_200_OK assert response.json() == expected_result - # connect integration to Slack - make_channel_filter(integration, notify_in_slack=True) + # connect integration to Slack (no channel means default channel) + channel_filter = make_channel_filter(integration, notify_in_slack=True) + + response = client.get(url, format="json", **make_user_auth_headers(user, token)) + assert response.status_code == status.HTTP_200_OK + expected_result["is_integration_chatops_connected"] = True + assert response.json() == expected_result + + # connect integration to Slack (set a channel) + channel_filter.slack_channel_id = "C123456" + channel_filter.save() response = client.get(url, format="json", **make_user_auth_headers(user, token)) assert response.status_code == status.HTTP_200_OK