zerver/decorator: Set request.client in api_key_only_webhook_view.

Previously, api_key_only_webhook_view passed 3 positional arguments
(request, user_profile, and client) into a function. However, most
of our other auth decorators only pass 2 positional arguments. For
the sake of consistency, we now make api_key_only_webhook_view set
request.client and pass only request and user_profile as positional
arguments.
This commit is contained in:
Eeshan Garg
2017-05-01 20:30:50 -02:30
committed by Tim Abbott
parent 2e0c03ae2d
commit e87e246fcb
46 changed files with 189 additions and 188 deletions

View File

@@ -7,7 +7,7 @@ from django.http import HttpRequest, HttpResponse
from zerver.lib.actions import check_send_message
from zerver.lib.response import json_success
from zerver.lib.request import JsonableError
from zerver.models import Client, UserProfile
from zerver.models import UserProfile
from zerver.decorator import api_key_only_webhook_view, REQ, has_request_variables
from zerver.lib.webhooks.git import get_issue_event_message, SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE,\
@@ -390,15 +390,14 @@ EVENT_FUNCTION_MAPPER = {
@api_key_only_webhook_view('GitHub')
@has_request_variables
def api_github_webhook(
request, user_profile, client,
payload=REQ(argument_type='body'), stream=REQ(default='github'),
branches=REQ(default=None)):
# type: (HttpRequest, UserProfile, Client, Dict[str, Any], Text, Text) -> HttpResponse
request, user_profile, payload=REQ(argument_type='body'),
stream=REQ(default='github'), branches=REQ(default=None)):
# type: (HttpRequest, UserProfile, Dict[str, Any], Text, Text) -> HttpResponse
event = get_event(request, payload, branches)
if event is not None:
subject = get_subject_based_on_type(payload, event)
body = get_body_function_based_on_type(event)(payload)
check_send_message(user_profile, client, 'stream', [stream], subject, body)
check_send_message(user_profile, request.client, 'stream', [stream], subject, body)
return json_success()
def get_event(request, payload, branches):