-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
zerver/fixtures/crashlytics/crashlytics_issue_message.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"event": "issue_impact_change", | ||
"payload_type": "issue", | ||
"payload": { | ||
"display_id": 123 , | ||
"title": "Issue Title" , | ||
"method": "methodName of issue", | ||
"impact_level": 2, | ||
"crashes_count": 54, | ||
"impacted_devices_count": 16, | ||
"url": "http://crashlytics.com/full/url/to/issue" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"event": "verification", | ||
"payload_type": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Webhooks for external integrations. | ||
from __future__ import absolute_import | ||
from django.utils.translation import ugettext as _ | ||
from zerver.lib.actions import check_send_message | ||
from zerver.lib.response import json_success, json_error | ||
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view | ||
|
||
|
||
CRASHLYTICS_SUBJECT_TEMPLATE = '{display_id}: {title}' | ||
CRASHLYTICS_MESSAGE_TEMPLATE = '[Issue]({url}) impacts at least {impacted_devices_count} device(s).' | ||
|
||
VERIFICATION_EVENT = 'verification' | ||
|
||
|
||
@api_key_only_webhook_view('Crashlytics') | ||
@has_request_variables | ||
def api_crashlytics_webhook(request, user_profile, client, payload=REQ(argument_type='body'), | ||
stream=REQ(default='crashlytics')): | ||
try: | ||
event = payload['event'] | ||
if event == VERIFICATION_EVENT: | ||
return json_success() | ||
issue_body = payload['payload'] | ||
subject = CRASHLYTICS_SUBJECT_TEMPLATE.format( | ||
display_id=issue_body['display_id'], | ||
title=issue_body['title'] | ||
) | ||
body = CRASHLYTICS_MESSAGE_TEMPLATE.format( | ||
impacted_devices_count=issue_body['impacted_devices_count'], | ||
url=issue_body['url'] | ||
) | ||
except KeyError as e: | ||
return json_error(_("Missing key {} in JSON".format(e.message))) | ||
|
||
check_send_message(user_profile, client, 'stream', [stream], | ||
subject, body) | ||
return json_success() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters