2022-06-06 16:07:28 -03:00
|
|
|
from apps.public_api.constants import VALID_DATE_FOR_DELETE_INCIDENT
|
2023-09-12 10:49:16 +01:00
|
|
|
from apps.slack.client import SlackClient
|
|
|
|
|
from apps.slack.errors import SlackAPITokenError
|
2022-06-03 08:09:47 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def team_has_slack_token_for_deleting(alert_group):
|
|
|
|
|
if alert_group.slack_message and alert_group.slack_message.slack_team_identity:
|
2023-09-12 10:49:16 +01:00
|
|
|
sc = SlackClient(alert_group.slack_message.slack_team_identity)
|
2022-06-03 08:09:47 -06:00
|
|
|
try:
|
2023-09-05 11:31:59 +02:00
|
|
|
sc.auth_test()
|
2023-09-12 10:49:16 +01:00
|
|
|
except SlackAPITokenError:
|
2022-06-03 08:09:47 -06:00
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_valid_group_creation_date(alert_group):
|
|
|
|
|
return alert_group.started_at.date() > VALID_DATE_FOR_DELETE_INCIDENT
|