|
@@ -8,9 +8,15 @@ import sentry_sdk
|
|
from django import forms
|
|
from django import forms
|
|
from django.utils.translation import ugettext_lazy as _
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
|
|
+from sentry import features
|
|
|
|
+
|
|
from sentry.models import Integration
|
|
from sentry.models import Integration
|
|
from sentry.rules.actions.base import IntegrationEventAction
|
|
from sentry.rules.actions.base import IntegrationEventAction
|
|
-from sentry.shared_integrations.exceptions import ApiError, DuplicateDisplayNameError
|
|
|
|
|
|
+from sentry.shared_integrations.exceptions import (
|
|
|
|
+ ApiError,
|
|
|
|
+ DeprecatedIntegrationError,
|
|
|
|
+ DuplicateDisplayNameError,
|
|
|
|
+)
|
|
from sentry.utils import metrics, json
|
|
from sentry.utils import metrics, json
|
|
|
|
|
|
from .client import SlackClient
|
|
from .client import SlackClient
|
|
@@ -83,6 +89,16 @@ class SlackNotifyServiceForm(forms.Form):
|
|
channel_prefix, channel_id, timed_out = self.channel_transformer(
|
|
channel_prefix, channel_id, timed_out = self.channel_transformer(
|
|
integration, channel
|
|
integration, channel
|
|
)
|
|
)
|
|
|
|
+ except DeprecatedIntegrationError:
|
|
|
|
+ raise forms.ValidationError(
|
|
|
|
+ _(
|
|
|
|
+ 'Workspace "%(workspace)s" is using the deprecated Slack integration. Please re-install your integration to enable Slack alerting again.',
|
|
|
|
+ ),
|
|
|
|
+ code="invalid",
|
|
|
|
+ params={
|
|
|
|
+ "workspace": dict(self.fields["workspace"].choices).get(int(workspace)),
|
|
|
|
+ },
|
|
|
|
+ )
|
|
except DuplicateDisplayNameError:
|
|
except DuplicateDisplayNameError:
|
|
domain = integration.metadata["domain_name"]
|
|
domain = integration.metadata["domain_name"]
|
|
|
|
|
|
@@ -151,6 +167,13 @@ class SlackNotifyServiceAction(IntegrationEventAction):
|
|
# Integration removed, rule still active.
|
|
# Integration removed, rule still active.
|
|
return
|
|
return
|
|
|
|
|
|
|
|
+ # XXX:(meredith) No longer support sending workspace app notifications unless explicitly
|
|
|
|
+ # flagged in. Flag is temporary and will be taken out shortly
|
|
|
|
+ if get_integration_type(integration) == "workspace_app" and not features.has(
|
|
|
|
+ "organizations:slack-allow-workspace", event.group.project.organization
|
|
|
|
+ ):
|
|
|
|
+ return
|
|
|
|
+
|
|
def send_notification(event, futures):
|
|
def send_notification(event, futures):
|
|
with sentry_sdk.start_transaction(
|
|
with sentry_sdk.start_transaction(
|
|
op=u"slack.send_notification", name=u"SlackSendNotification", sampled=1.0
|
|
op=u"slack.send_notification", name=u"SlackSendNotification", sampled=1.0
|
|
@@ -159,7 +182,8 @@ class SlackNotifyServiceAction(IntegrationEventAction):
|
|
attachments = [
|
|
attachments = [
|
|
build_group_attachment(event.group, event=event, tags=tags, rules=rules)
|
|
build_group_attachment(event.group, event=event, tags=tags, rules=rules)
|
|
]
|
|
]
|
|
- # check if we should have the upgrade notice attachment
|
|
|
|
|
|
+ # XXX(meredith): Needs to be ripped out along with above feature flag. This will
|
|
|
|
+ # not be used unless someone was explicitly flagged in to continue workspace alerts
|
|
integration_type = get_integration_type(integration)
|
|
integration_type = get_integration_type(integration)
|
|
if integration_type == "workspace_app":
|
|
if integration_type == "workspace_app":
|
|
# stick the upgrade attachment first
|
|
# stick the upgrade attachment first
|