mirror of https://github.com/zulip/zulip.git
webhooks: Derive payload from request itself.
This commit is contained in:
parent
a1f5f6502c
commit
4917391133
|
@ -266,10 +266,13 @@ def access_user_by_api_key(request: HttpRequest, api_key: str, email: Optional[s
|
|||
def log_exception_to_webhook_logger(
|
||||
request: HttpRequest,
|
||||
summary: str,
|
||||
payload: str,
|
||||
unsupported_event: bool,
|
||||
) -> None:
|
||||
if request.content_type == 'application/json':
|
||||
payload = request.body
|
||||
else:
|
||||
payload = request.POST.get('payload')
|
||||
|
||||
try:
|
||||
payload = orjson.dumps(orjson.loads(payload), option=orjson.OPT_INDENT_2).decode()
|
||||
except orjson.JSONDecodeError:
|
||||
|
@ -352,7 +355,6 @@ def webhook_view(
|
|||
log_exception_to_webhook_logger(
|
||||
request=request,
|
||||
summary=str(err),
|
||||
payload=request.body,
|
||||
unsupported_event=isinstance(err, UnsupportedWebhookEventType),
|
||||
)
|
||||
raise err
|
||||
|
@ -604,7 +606,6 @@ def authenticated_rest_api_view(
|
|||
log_exception_to_webhook_logger(
|
||||
request=request,
|
||||
summary=str(err),
|
||||
payload=request_body,
|
||||
unsupported_event=isinstance(err, UnsupportedWebhookEventType),
|
||||
)
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ class Helper:
|
|||
log_exception_to_webhook_logger(
|
||||
request=request,
|
||||
summary=summary,
|
||||
payload=request.body,
|
||||
unsupported_event=True,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue