mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
request: Refactor remote_server into RequestNotes.
This eliminates the possibility of having `request.user` as `RemoteZulipServer` by refactoring it as an attribute of `RequestNotes`. So we can effectively narrow the type of `request.user` by testing `user.is_authenticated` in most cases (except that of `SCIMClient`) in code paths that require access to `.format_requestor_for_logs` where we previously expect either `UserProfile` or `RemoteZulipServer` backed by the implied polymorphism. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
3bc78d2473
commit
b02779c005
@@ -299,7 +299,8 @@ class HostRequestMock(HttpRequest):
|
||||
def __init__(
|
||||
self,
|
||||
post_data: Dict[str, Any] = {},
|
||||
user_profile: Union[UserProfile, RemoteZulipServer, None] = None,
|
||||
user_profile: Union[UserProfile, None] = None,
|
||||
remote_server: Optional[RemoteZulipServer] = None,
|
||||
host: str = settings.EXTERNAL_HOST,
|
||||
client_name: Optional[str] = None,
|
||||
meta_data: Optional[Dict[str, Any]] = None,
|
||||
@@ -335,6 +336,7 @@ class HostRequestMock(HttpRequest):
|
||||
log_data={},
|
||||
tornado_handler_id=None if tornado_handler is None else tornado_handler.handler_id,
|
||||
client=get_client(client_name) if client_name is not None else None,
|
||||
remote_server=remote_server,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user