webhooks: Fix Jira webhook constructing subject still too early.

For event types that we don't yet support, like worklog_created (and
likely many more in the future), it doesn't make sense to call a
function that only parses issue events correctly.
This commit is contained in:
Tim Abbott
2020-03-27 06:19:00 -07:00
parent 3abb52476c
commit cb1fb94ac8

View File

@@ -19,6 +19,8 @@ IGNORED_EVENTS = [
'issuelink_deleted', 'issuelink_deleted',
'sprint_started', 'sprint_started',
'sprint_closed', 'sprint_closed',
'worklog_created',
'worklog_updated',
] ]
def guess_zulip_user_from_jira(jira_username: str, realm: Realm) -> Optional[UserProfile]: def guess_zulip_user_from_jira(jira_username: str, realm: Realm) -> Optional[UserProfile]:
@@ -322,13 +324,12 @@ def api_jira_webhook(request: HttpRequest, user_profile: UserProfile,
if event in IGNORED_EVENTS: if event in IGNORED_EVENTS:
return json_success() return json_success()
subject = get_issue_subject(payload)
content_func = get_event_handler(event) content_func = get_event_handler(event)
if content_func is None: if content_func is None:
raise UnexpectedWebhookEventType('Jira', event) raise UnexpectedWebhookEventType('Jira', event)
subject = get_issue_subject(payload)
content = content_func(payload, user_profile) # type: str content = content_func(payload, user_profile) # type: str
check_send_webhook_message(request, user_profile, check_send_webhook_message(request, user_profile,