diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b69f014..fa6cd1a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ### Improvements - Rate limiting for Telegram notifications (10 notifications per chat per minute) +- Use Slack V2 OAuth flow ### Bug Fixes - "Get a single check" API call now supports read-only API keys (#346) diff --git a/hc/api/models.py b/hc/api/models.py index 38fc2afd..7089b5da 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -528,7 +528,11 @@ class Channel(models.Model): return None doc = json.loads(self.value) - return doc["team_name"] + if "team_name" in doc: + return doc["team_name"] + + if "team" in doc: + return doc["team"]["name"] @property def slack_channel(self): diff --git a/hc/front/views.py b/hc/front/views.py index bc547b35..6d3e4c53 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -1037,7 +1037,7 @@ def add_slack_btn(request, code): project = _get_project_for_user(request, code) state = token_urlsafe() - authorize_url = "https://slack.com/oauth/authorize?" + urlencode( + authorize_url = "https://slack.com/oauth/v2/authorize?" + urlencode( { "scope": "incoming-webhook", "client_id": settings.SLACK_CLIENT_ID, @@ -1071,7 +1071,7 @@ def add_slack_complete(request): return HttpResponseForbidden() result = requests.post( - "https://slack.com/api/oauth.access", + "https://slack.com/api/oauth.v2.access", { "client_id": settings.SLACK_CLIENT_ID, "client_secret": settings.SLACK_CLIENT_SECRET,