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 zerver.decorator import REQ, has_request_variables, api_key_only_webhook_vi
from zerver.lib.actions import check_send_message
from zerver.lib.response import json_success
from zerver.lib.validator import check_dict, check_string, check_bool
from zerver.models import UserProfile, Client
from zerver.models import UserProfile
from typing import Dict
import ujson
@@ -23,7 +23,7 @@ MESSAGE_TEMPLATE = (
@api_key_only_webhook_view('Travis')
@has_request_variables
def api_travis_webhook(request, user_profile, client,
def api_travis_webhook(request, user_profile,
stream=REQ(default='travis'),
topic=REQ(default=None),
ignore_pull_requests=REQ(validator=check_bool, default=True),
@@ -32,7 +32,7 @@ def api_travis_webhook(request, user_profile, client,
('status_message', check_string),
('compare_url', check_string),
]))):
# type: (HttpRequest, UserProfile, Client, str, str, str, Dict[str, str]) -> HttpResponse
# type: (HttpRequest, UserProfile, str, str, str, Dict[str, str]) -> HttpResponse
message_status = message['status_message']
if ignore_pull_requests and message['type'] == 'pull_request':
@@ -53,5 +53,5 @@ def api_travis_webhook(request, user_profile, client,
message['build_url']
)
check_send_message(user_profile, client, 'stream', [stream], topic, body)
check_send_message(user_profile, request.client, 'stream', [stream], topic, body)
return json_success()