mirror of https://github.com/zulip/zulip.git
webhooks: Convert non-body payload webhooks to use @typed_endpoint.
These webhooks do not use argument_type_is_body, so they are parsing the payload from a query parameter directly into WildValue.
This commit is contained in:
parent
318a9316a7
commit
b163f2fe4e
|
@ -1,11 +1,13 @@
|
|||
from typing import Dict, List
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from pydantic import Json
|
||||
from typing_extensions import Annotated
|
||||
|
||||
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 ApiParamConfig, 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
|
||||
|
||||
|
@ -56,11 +58,12 @@ def get_recipients_text(recipients: List[str]) -> str:
|
|||
|
||||
|
||||
@webhook_view("HelloSign")
|
||||
@has_request_variables
|
||||
@typed_endpoint
|
||||
def api_hellosign_webhook(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
payload: WildValue = REQ(whence="json", converter=to_wild_value),
|
||||
*,
|
||||
payload: Annotated[Json[WildValue], ApiParamConfig("json")],
|
||||
) -> HttpResponse:
|
||||
if "signature_request" in payload:
|
||||
body = get_message_body(payload)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import gettext as _
|
||||
from pydantic import Json
|
||||
|
||||
from zerver.decorator import webhook_view
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
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 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
|
||||
|
||||
|
@ -19,11 +20,12 @@ SEARCH_TEMPLATE = """
|
|||
|
||||
|
||||
@webhook_view("Papertrail")
|
||||
@has_request_variables
|
||||
@typed_endpoint
|
||||
def api_papertrail_webhook(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
payload: WildValue = REQ(converter=to_wild_value),
|
||||
*,
|
||||
payload: Json[WildValue],
|
||||
) -> HttpResponse:
|
||||
if "events" not in payload:
|
||||
raise JsonableError(_("Events key is missing from payload"))
|
||||
|
|
Loading…
Reference in New Issue