Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

intercom: Return success on HEAD requests.

Zixuan James Li1e36d79b838a
diff --git a/zerver/webhooks/intercom/tests.py b/zerver/webhooks/intercom/tests.py
index 2ffad3f0a9a..dbd813c86a4 100644
--- a/zerver/webhooks/intercom/tests.py
+++ b/zerver/webhooks/intercom/tests.py
@@ -265,3 +265,7 @@ New user created:
"Contact: Eeshan Garg",
"User unsubscribed from emails.",
)
+
+ def test_success_on_http_head(self) -> None:
+ result = self.client_head(self.url)
+ self.assertEqual(result.status_code, 200)
diff --git a/zerver/webhooks/intercom/view.py b/zerver/webhooks/intercom/view.py
index 9eb2cccbfee..19f5544e290 100644
--- a/zerver/webhooks/intercom/view.py
+++ b/zerver/webhooks/intercom/view.py
@@ -4,7 +4,7 @@ from typing import Callable, Dict, List, Tuple
from django.http import HttpRequest, HttpResponse
-from zerver.decorator import webhook_view
+from zerver.decorator import return_success_on_head_request, webhook_view
from zerver.lib.exceptions import UnsupportedWebhookEventTypeError
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success
@@ -325,6 +325,8 @@ ALL_EVENT_TYPES = list(EVENT_TO_FUNCTION_MAPPER.keys())
@webhook_view("Intercom", all_event_types=ALL_EVENT_TYPES)
+# Intercom sends a HEAD request to validate the webhook URL. In this case, we just assume success.
+@return_success_on_head_request
@has_request_variables
def api_intercom_webhook(
request: HttpRequest,