# What this PR does - Rename `SlackClientWithErrorHandling` to just `SlackClient` - Add more error classes + improve the way errors are raised based on the Slack error code - Add API call retries on Slack server errors (e.g. when Slack returns `5xx` errors) - Refactor some methods working with Slack API + add tests ## Which issue(s) this PR fixes - https://github.com/grafana/oncall-private/issues/1837 - https://github.com/grafana/oncall-private/issues/1840 - https://github.com/grafana/oncall-private/issues/1842 ## 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)
17 lines
609 B
Python
17 lines
609 B
Python
from apps.public_api.constants import VALID_DATE_FOR_DELETE_INCIDENT
|
|
from apps.slack.client import SlackClient
|
|
from apps.slack.errors import SlackAPITokenError
|
|
|
|
|
|
def team_has_slack_token_for_deleting(alert_group):
|
|
if alert_group.slack_message and alert_group.slack_message.slack_team_identity:
|
|
sc = SlackClient(alert_group.slack_message.slack_team_identity)
|
|
try:
|
|
sc.auth_test()
|
|
except SlackAPITokenError:
|
|
return False
|
|
return True
|
|
|
|
|
|
def is_valid_group_creation_date(alert_group):
|
|
return alert_group.started_at.date() > VALID_DATE_FOR_DELETE_INCIDENT
|