diff --git a/engine/apps/slack/models/slack_message.py b/engine/apps/slack/models/slack_message.py index 789886e4..c6bbcff6 100644 --- a/engine/apps/slack/models/slack_message.py +++ b/engine/apps/slack/models/slack_message.py @@ -11,6 +11,7 @@ from apps.slack.errors import ( SlackAPIError, SlackAPIFetchMembersFailedError, SlackAPIMethodNotSupportedForChannelTypeError, + SlackAPIRatelimitError, SlackAPITokenError, ) @@ -146,6 +147,18 @@ class SlackMessage(models.Model): thread_ts=slack_message.slack_id, unfurl_links=True, ) + except SlackAPIRatelimitError: + UserNotificationPolicyLogRecord( + author=user, + type=UserNotificationPolicyLogRecord.TYPE_PERSONAL_NOTIFICATION_FAILED, + notification_policy=notification_policy, + alert_group=alert_group, + reason="Slack API rate limit error", + notification_step=notification_policy.step, + notification_channel=notification_policy.notify_by, + notification_error_code=UserNotificationPolicyLogRecord.ERROR_NOTIFICATION_IN_SLACK_RATELIMIT, + ).save() + return except SlackAPITokenError: UserNotificationPolicyLogRecord( author=user,