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.

webhooks: In logger, pull user from request, rather than parameter.

Alex Vandivera1f5f6502cf6
diff --git a/zerver/decorator.py b/zerver/decorator.py
index 173e5f3ab32..ee074f03edc 100644
--- a/zerver/decorator.py
+++ b/zerver/decorator.py
@@ -265,7 +265,6 @@ def access_user_by_api_key(request: HttpRequest, api_key: str, email: Optional[s
def log_exception_to_webhook_logger(
request: HttpRequest,
- user_profile: UserProfile,
summary: str,
payload: str,
unsupported_event: bool,
@@ -299,8 +298,8 @@ body:
{body}
""".format(
summary=summary,
- email=user_profile.delivery_email,
- realm=user_profile.realm.string_id,
+ email=request.user.delivery_email,
+ realm=request.user.realm.string_id,
client_name=request.client.name,
body=payload,
path_info=request.META.get('PATH_INFO', None),
@@ -352,7 +351,6 @@ def webhook_view(
err.webhook_name = webhook_client_name
log_exception_to_webhook_logger(
request=request,
- user_profile=user_profile,
summary=str(err),
payload=request.body,
unsupported_event=isinstance(err, UnsupportedWebhookEventType),
@@ -605,7 +603,6 @@ def authenticated_rest_api_view(
if request_body is not None:
log_exception_to_webhook_logger(
request=request,
- user_profile=profile,
summary=str(err),
payload=request_body,
unsupported_event=isinstance(err, UnsupportedWebhookEventType),
diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py
index a6403a2125e..a894a102ee4 100644
--- a/zerver/webhooks/github/view.py
+++ b/zerver/webhooks/github/view.py
@@ -33,21 +33,18 @@ class Helper:
def __init__(
self,
request: HttpRequest,
- user_profile: UserProfile,
payload: Dict[str, Any],
include_title: bool,
) -> None:
self.payload = payload
self.include_title = include_title
self._request = request
- self._user_profile = user_profile
def log_unsupported(self, event: str) -> None:
summary = f"The '{event}' event isn't currently supported by the GitHub webhook"
request = self._request
log_exception_to_webhook_logger(
request=request,
- user_profile=self._user_profile,
summary=summary,
payload=request.body,
unsupported_event=True,
@@ -635,7 +632,6 @@ def api_github_webhook(
helper = Helper(
request=request,
- user_profile=user_profile,
payload=payload,
include_title=user_specified_topic is not None,
)