Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
canarytoken: Strengthen types using WildValue.
Anders Kaseorg02393ecad754
diff --git a/zerver/webhooks/canarytoken/view.py b/zerver/webhooks/canarytoken/view.pyindex ca6713841dc..6b5ba4d685f 100644--- a/zerver/webhooks/canarytoken/view.py+++ b/zerver/webhooks/canarytoken/view.py@@ -1,11 +1,12 @@# Webhooks for external integrations.-from typing import Any, Dict, Optional+from typing import Optionalfrom 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_string, to_wild_valuefrom zerver.lib.webhooks.common import check_send_webhook_messagefrom zerver.models import UserProfile@@ -15,7 +16,7 @@ from zerver.models import UserProfiledef api_canarytoken_webhook(request: HttpRequest,user_profile: UserProfile,- message: Dict[str, Any] = REQ(argument_type="body"),+ message: WildValue = REQ(argument_type="body", converter=to_wild_value),user_specified_topic: Optional[str] = REQ("topic", default=None),) -> HttpResponse:"""@@ -28,9 +29,9 @@ def api_canarytoken_webhook("""topic = "canarytoken alert"body = (- f"**:alert: Canarytoken has been triggered on {message['time']}!**\n\n"- f"{message['memo']} \n\n"- f"[Manage this canarytoken]({message['manage_url']})"+ f"**:alert: Canarytoken has been triggered on {message['time'].tame(check_string)}!**\n\n"+ f"{message['memo'].tame(check_string)} \n\n"+ f"[Manage this canarytoken]({message['manage_url'].tame(check_string)})")if user_specified_topic: