Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
webhooks: Migrate librato to use @typed_endpoint.
Zixuan James Li4037196fb214
diff --git a/zerver/webhooks/librato/view.py b/zerver/webhooks/librato/view.pyindex 0f3489b82d6..9caa9b126ea 100644--- a/zerver/webhooks/librato/view.py+++ b/zerver/webhooks/librato/view.py@@ -4,12 +4,12 @@ from typing import Any, Callable, Dict, List, Mapping, Tupleimport orjsonfrom django.http import HttpRequest, HttpResponsefrom django.utils.translation import gettext as _+from pydantic import Jsonfrom zerver.decorator import webhook_viewfrom zerver.lib.exceptions import JsonableError-from zerver.lib.request import REQ, has_request_variablesfrom zerver.lib.response import json_success-from zerver.lib.validator import check_dict+from zerver.lib.typed_endpoint import typed_endpointfrom zerver.lib.webhooks.common import check_send_webhook_messagefrom zerver.models import UserProfile@@ -159,11 +159,14 @@ class LibratoWebhookHandler(LibratoWebhookParser):@webhook_view("Librato")-@has_request_variables+@typed_endpointdef api_librato_webhook(request: HttpRequest,user_profile: UserProfile,- payload: Mapping[str, Any] = REQ(json_validator=check_dict(), default={}),+ *,+ payload: Json[+ Mapping[str, Any]+ ] = {}, # noqa: B006 # Mapping is indeed immutable, but Json's type annotation drops that information) -> HttpResponse:try:attachments = orjson.loads(request.body).get("attachments", [])