Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
delighted: Strengthen types using WildValue.
Christopher Chong990a046fc707
diff --git a/zerver/webhooks/delighted/view.py b/zerver/webhooks/delighted/view.pyindex fa6950176eb..6db833ec913 100644--- a/zerver/webhooks/delighted/view.py+++ b/zerver/webhooks/delighted/view.py@@ -1,10 +1,9 @@-from typing import Any, Dict-from django.http import HttpRequest, HttpResponsefrom zerver.decorator import webhook_viewfrom zerver.lib.request import REQ, has_request_variablesfrom zerver.lib.response import json_success+from zerver.lib.validator import WildValue, check_int, check_string, to_wild_valuefrom zerver.lib.webhooks.common import check_send_webhook_messagefrom zerver.models import UserProfile@@ -37,15 +36,15 @@ def body_template(score: int) -> str:def api_delighted_webhook(request: HttpRequest,user_profile: UserProfile,- payload: Dict[str, Dict[str, Any]] = REQ(argument_type="body"),+ payload: WildValue = REQ(argument_type="body", converter=to_wild_value),) -> HttpResponse:person = payload["event_data"]["person"]- selected_payload = {"email": person["email"]}- selected_payload["score"] = payload["event_data"]["score"]- selected_payload["comment"] = payload["event_data"]["comment"]+ email = person["email"].tame(check_string)+ score = payload["event_data"]["score"].tame(check_int)+ comment = payload["event_data"]["comment"].tame(check_string)- BODY_TEMPLATE = body_template(selected_payload["score"])- body = BODY_TEMPLATE.format(**selected_payload)+ BODY_TEMPLATE = body_template(score)+ body = BODY_TEMPLATE.format(email=email, score=score, comment=comment)topic = "Survey response"check_send_webhook_message(request, user_profile, topic, body)