logging_util: Remove dependence on get_current_request.

Pass the HttpRequest explicitly through the two webhooks that log to
the webhook loggers.

get_current_request is now unused, so remove it (in the same commit
for test coverage reasons).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-07-10 16:17:30 -04:00
committed by Tim Abbott
parent f66e2c3112
commit 63be67af80
9 changed files with 85 additions and 95 deletions

View File

@@ -48,17 +48,17 @@ DISCUSSION_COMMENT_TEMPLATE = "{author} [commented]({comment_url}) on [discussio
class Helper:
def __init__(
self,
request: HttpRequest,
payload: WildValue,
include_title: bool,
) -> None:
self.request = request
self.payload = payload
self.include_title = include_title
def log_unsupported(self, event: str) -> None:
summary = f"The '{event}' event isn't currently supported by the GitHub webhook; ignoring"
log_unsupported_webhook_event(
summary=summary,
)
log_unsupported_webhook_event(request=self.request, summary=summary)
def get_opened_or_update_pull_request_body(helper: Helper) -> str:
@@ -836,6 +836,7 @@ def api_github_webhook(
body_function = EVENT_FUNCTION_MAPPER[event]
helper = Helper(
request=request,
payload=payload,
include_title=user_specified_topic is not None,
)