Skip to content

Commit e8d8ffa

Browse files
committed
added to link_identity
1 parent f85429b commit e8d8ffa

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/sentry/integrations/slack/link_identity.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
from __future__ import absolute_import, print_function
22

3+
import six
4+
35
from django.core.urlresolvers import reverse
46
from django.db import IntegrityError
57
from django.http import Http404
68
from django.utils import timezone
79
from django.views.decorators.cache import never_cache
810

9-
from sentry import http
1011
from sentry.models import Integration, Identity, IdentityProvider, IdentityStatus, Organization
1112
from sentry.utils.http import absolute_uri
1213
from sentry.utils.signing import sign, unsign
14+
from sentry.web.decorators import transaction_start
1315
from sentry.web.frontend.base import BaseView
1416
from sentry.web.helpers import render_to_response
17+
from sentry.shared_integrations.exceptions import ApiError
1518

16-
from .utils import logger, track_response_code
19+
from .client import SlackClient
20+
from .utils import logger
1721

1822

1923
def build_linking_url(integration, organization, slack_id, channel_id, response_url):
@@ -31,6 +35,7 @@ def build_linking_url(integration, organization, slack_id, channel_id, response_
3135

3236

3337
class SlackLinkIdentityView(BaseView):
38+
@transaction_start("SlackLinkIdentityView")
3439
@never_cache
3540
def handle(self, request, signed_params):
3641
params = unsign(signed_params.encode("ascii", errors="ignore"))
@@ -82,19 +87,18 @@ def handle(self, request, signed_params):
8287
"text": "Your Slack identity has been linked to your Sentry account. You're good to go!",
8388
}
8489

85-
session = http.build_session()
86-
req = session.post(params["response_url"], json=payload)
87-
status_code = req.status_code
88-
resp = req.json()
89-
90-
# If the user took their time to link their slack account, we may no
91-
# longer be able to respond, and we're not guaranteed able to post into
92-
# the channel. Ignore Expired url errors.
93-
#
94-
# XXX(epurkhiser): Yes the error string has a space in it.
95-
if not resp.get("ok") and resp.get("error") != "Expired url":
96-
logger.error("slack.link-notify.response-error", extra={"response": resp})
97-
track_response_code(status_code, resp.get("ok"))
90+
client = SlackClient()
91+
try:
92+
client.post(params["response_url"], data=payload, json=True)
93+
except ApiError as e:
94+
message = six.text_type(e)
95+
# If the user took their time to link their slack account, we may no
96+
# longer be able to respond, and we're not guaranteed able to post into
97+
# the channel. Ignore Expired url errors.
98+
#
99+
# XXX(epurkhiser): Yes the error string has a space in it.
100+
if message != "Expired url":
101+
logger.error("slack.link-notify.response-error", extra={"error": message})
98102

99103
return render_to_response(
100104
"sentry/slack-linked.html",

src/sentry/web/frontend/pipeline_advancer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from sentry.identity.pipeline import IdentityProviderPipeline
88
from sentry.integrations.pipeline import IntegrationPipeline
99
from sentry.web.frontend.base import BaseView
10+
from sentry.web.decorators import transaction_start
1011

1112

1213
# The request doesn't contain the pipeline type (pipeline information is stored
@@ -28,6 +29,7 @@ class PipelineAdvancerView(BaseView):
2829

2930
csrf_protect = False
3031

32+
@transaction_start("PipelineAdvancerView")
3133
def handle(self, request, provider_id):
3234
pipeline = None
3335

0 commit comments

Comments
 (0)