mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
webhooks: Migrate most webhooks to use @typed_endpoint.
This converts most webhook integration views to use @typed_endpoint instead of @has_request_variables, rewriting REQ parameters. For these webhooks, it simply requires switching the decorator, rewriting the type annotation of payload/message to WebhookPayload[WildValue], and removing the REQ default that defines the to_wild_value converter.
This commit is contained in:
committed by
Tim Abbott
parent
574740dda4
commit
9377080f1f
@@ -1,9 +1,9 @@
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import webhook_view
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.validator import WildValue, check_string, to_wild_value
|
||||
from zerver.lib.typed_endpoint import WebhookPayload, typed_endpoint
|
||||
from zerver.lib.validator import WildValue, check_string
|
||||
from zerver.lib.webhooks.common import check_send_webhook_message
|
||||
from zerver.models import UserProfile
|
||||
|
||||
@@ -17,11 +17,12 @@ APPVEYOR_MESSAGE_TEMPLATE = """
|
||||
|
||||
|
||||
@webhook_view("Appveyor")
|
||||
@has_request_variables
|
||||
@typed_endpoint
|
||||
def api_appveyor_webhook(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
payload: WildValue = REQ(argument_type="body", converter=to_wild_value),
|
||||
*,
|
||||
payload: WebhookPayload[WildValue],
|
||||
) -> HttpResponse:
|
||||
body = get_body_for_http_request(payload)
|
||||
topic = get_topic_for_http_request(payload)
|
||||
|
||||
Reference in New Issue
Block a user