mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
intercom: Return success on HEAD requests.
Intercom sends a HEAD request to validate the webhook URL on their side, which was not expected in the previous implementation. This fixes the problem that we send out a confusing error message for it. Fixes #23912. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
6fb4f10abb
commit
1e36d79b83
@@ -265,3 +265,7 @@ New user created:
|
|||||||
"Contact: Eeshan Garg",
|
"Contact: Eeshan Garg",
|
||||||
"User unsubscribed from emails.",
|
"User unsubscribed from emails.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_success_on_http_head(self) -> None:
|
||||||
|
result = self.client_head(self.url)
|
||||||
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from typing import Callable, Dict, List, Tuple
|
|||||||
|
|
||||||
from django.http import HttpRequest, HttpResponse
|
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.exceptions import UnsupportedWebhookEventTypeError
|
||||||
from zerver.lib.request import REQ, has_request_variables
|
from zerver.lib.request import REQ, has_request_variables
|
||||||
from zerver.lib.response import json_success
|
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)
|
@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
|
@has_request_variables
|
||||||
def api_intercom_webhook(
|
def api_intercom_webhook(
|
||||||
request: HttpRequest,
|
request: HttpRequest,
|
||||||
|
|||||||
Reference in New Issue
Block a user