8
8
from django import forms
9
9
from django .utils .translation import ugettext_lazy as _
10
10
11
+ from sentry import features
12
+
11
13
from sentry .models import Integration
12
14
from sentry .rules .actions .base import IntegrationEventAction
13
- from sentry .shared_integrations .exceptions import ApiError , DuplicateDisplayNameError
15
+ from sentry .shared_integrations .exceptions import (
16
+ ApiError ,
17
+ DeprecatedIntegrationError ,
18
+ DuplicateDisplayNameError ,
19
+ )
14
20
from sentry .utils import metrics , json
15
21
16
22
from .client import SlackClient
@@ -83,6 +89,16 @@ def clean(self):
83
89
channel_prefix , channel_id , timed_out = self .channel_transformer (
84
90
integration , channel
85
91
)
92
+ except DeprecatedIntegrationError :
93
+ raise forms .ValidationError (
94
+ _ (
95
+ 'Workspace "%(workspace)s" is using the deprecated Slack integration. Please re-install your integration to enable Slack alerting again.' ,
96
+ ),
97
+ code = "invalid" ,
98
+ params = {
99
+ "workspace" : dict (self .fields ["workspace" ].choices ).get (int (workspace )),
100
+ },
101
+ )
86
102
except DuplicateDisplayNameError :
87
103
domain = integration .metadata ["domain_name" ]
88
104
@@ -151,6 +167,13 @@ def after(self, event, state):
151
167
# Integration removed, rule still active.
152
168
return
153
169
170
+ # XXX:(meredith) No longer support sending workspace app notifications unless explicitly
171
+ # flagged in. Flag is temporary and will be taken out shortly
172
+ if get_integration_type (integration ) == "workspace_app" and not features .has (
173
+ "organizations:slack-allow-workspace" , event .group .project .organization
174
+ ):
175
+ return
176
+
154
177
def send_notification (event , futures ):
155
178
with sentry_sdk .start_transaction (
156
179
op = u"slack.send_notification" , name = u"SlackSendNotification" , sampled = 1.0
@@ -159,7 +182,8 @@ def send_notification(event, futures):
159
182
attachments = [
160
183
build_group_attachment (event .group , event = event , tags = tags , rules = rules )
161
184
]
162
- # check if we should have the upgrade notice attachment
185
+ # XXX(meredith): Needs to be ripped out along with above feature flag. This will
186
+ # not be used unless someone was explicitly flagged in to continue workspace alerts
163
187
integration_type = get_integration_type (integration )
164
188
if integration_type == "workspace_app" :
165
189
# stick the upgrade attachment first
0 commit comments