webhooks/updown: Fix a JsonableError to provide a real error message.

This commit is contained in:
Greg Price
2017-07-20 16:55:10 -07:00
committed by Tim Abbott
parent 6dfb46dc08
commit 7cd621bc9d
2 changed files with 4 additions and 7 deletions

View File

@@ -39,6 +39,7 @@ IGNORED_PHRASES = [
r'Terms of Service', r'Terms of Service',
r"URL", r"URL",
r"Ubuntu", r"Ubuntu",
r"Updown",
r"V5", r"V5",
r"Webathena", r"Webathena",
r"Windows", r"Windows",

View File

@@ -5,19 +5,15 @@ from datetime import datetime
from typing import Any, Dict, List from typing import Any, Dict, List
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from zerver.lib.actions import check_send_message from zerver.lib.actions import check_send_message
from zerver.lib.exceptions import JsonableError
from zerver.lib.response import json_success, json_error from zerver.lib.response import json_success, json_error
from zerver.lib.request import JsonableError
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from zerver.models import UserProfile, Client from zerver.models import UserProfile, Client
SUBJECT_TEMPLATE = "{service_url}" SUBJECT_TEMPLATE = "{service_url}"
class UnsupportedUpdownEventType(JsonableError):
pass
def send_message_for_event(event, user_profile, client, stream): def send_message_for_event(event, user_profile, client, stream):
# type: (Dict[str, Any], UserProfile, Client, str) -> None # type: (Dict[str, Any], UserProfile, Client, str) -> None
try: try:
@@ -88,4 +84,4 @@ def get_event_type(event):
event_type = event_type_match.group(1) event_type = event_type_match.group(1)
if event_type in EVENT_TYPE_BODY_MAPPER: if event_type in EVENT_TYPE_BODY_MAPPER:
return event_type return event_type
raise UnsupportedUpdownEventType(event['event']) raise JsonableError(_('Unsupported Updown event type: %s') % (event['event'],))