mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
Don't handle json payload key errors inside webhooks.
Fixes first part of #6213.
This commit is contained in:
@@ -22,23 +22,20 @@ VERIFICATION_EVENT = 'verification'
|
||||
def api_crashlytics_webhook(request, user_profile, payload=REQ(argument_type='body'),
|
||||
stream=REQ(default='crashlytics')):
|
||||
# type: (HttpRequest, UserProfile, Dict[str, Any], Text) -> HttpResponse
|
||||
try:
|
||||
event = payload['event']
|
||||
if event == VERIFICATION_EVENT:
|
||||
subject = CRASHLYTICS_SETUP_SUBJECT_TEMPLATE
|
||||
body = CRASHLYTICS_SETUP_MESSAGE_TEMPLATE
|
||||
else:
|
||||
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(str(e))))
|
||||
event = payload['event']
|
||||
if event == VERIFICATION_EVENT:
|
||||
subject = CRASHLYTICS_SETUP_SUBJECT_TEMPLATE
|
||||
body = CRASHLYTICS_SETUP_MESSAGE_TEMPLATE
|
||||
else:
|
||||
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']
|
||||
)
|
||||
|
||||
check_send_message(user_profile, request.client, 'stream', [stream],
|
||||
subject, body)
|
||||
|
||||
Reference in New Issue
Block a user