request: Store client information using ZulipRequestNotes.

This concludes the HttpRequest migration to eliminate arbitrary
attributes (except private ones that are belong to django) attached
to the request object during runtime and migrated them to a
separate data structure dedicated for the purpose of adding
information (so called notes) to a HttpRequest.
This commit is contained in:
PIG208
2021-07-10 00:10:51 +08:00
committed by Tim Abbott
parent 26875cdf0b
commit c03b9c95ad
20 changed files with 89 additions and 55 deletions

View File

@@ -276,9 +276,13 @@ class ZulipWebhookFormatter(ZulipFormatter):
)
header_message = header_text if header_text else None
from zerver.lib.request import get_request_notes
client = get_request_notes(request).client
assert client is not None
setattr(record, "user", f"{request.user.delivery_email} ({request.user.realm.string_id})")
setattr(record, "client", request.client.name)
setattr(record, "client", client.name)
setattr(record, "url", request.META.get("PATH_INFO", None))
setattr(record, "content_type", request.content_type)
setattr(record, "custom_headers", header_message)