From c41ead698f260d1e68fda0c660b2d0ef07329ce5 Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 2 Nov 2021 07:11:33 -0400 Subject: [PATCH] Matrix bridge: Rename username to mxid. The username doesn't include the Matrix homeserver domain name, while the mxid does. Since we change the usage of the old "username" to include the domain, it is incorrect to remain saying it as "username." --- zulip/integrations/bridge_with_matrix/matrix_bridge.py | 8 ++++---- zulip/integrations/bridge_with_matrix/test_matrix.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zulip/integrations/bridge_with_matrix/matrix_bridge.py b/zulip/integrations/bridge_with_matrix/matrix_bridge.py index 77e532c..9b8dd3d 100644 --- a/zulip/integrations/bridge_with_matrix/matrix_bridge.py +++ b/zulip/integrations/bridge_with_matrix/matrix_bridge.py @@ -39,10 +39,10 @@ class Bridge_ZulipFatalException(Exception): def matrix_login(matrix_client: Any, matrix_config: Dict[str, Any]) -> None: try: - matrix_client.login_with_password(matrix_config["username"], matrix_config["password"]) + matrix_client.login_with_password(matrix_config["mxid"], matrix_config["password"]) except MatrixRequestError as exception: if exception.code == 403: - raise Bridge_FatalMatrixException("Bad username or password.") + raise Bridge_FatalMatrixException("Bad mxid or password.") else: raise Bridge_FatalMatrixException("Check if your server details are correct.") except MissingSchema: @@ -77,7 +77,7 @@ def matrix_to_zulip( """ content = get_message_content_from_event(event, no_noise) - zulip_bot_user = matrix_config["username"] + zulip_bot_user = matrix_config["mxid"] # We do this to identify the messages generated from Zulip -> Matrix # and we make sure we don't forward it again to the Zulip stream. not_from_zulip_bot = event["sender"] != zulip_bot_user @@ -237,7 +237,7 @@ def write_sample_config(target_path: str, zuliprc: Optional[str]) -> None: OrderedDict( ( ("host", "https://matrix.org"), - ("username", "@username:matrix.org"), + ("mxid", "@username:matrix.org"), ("password", "password"), ("room_id", "#zulip:matrix.org"), ) diff --git a/zulip/integrations/bridge_with_matrix/test_matrix.py b/zulip/integrations/bridge_with_matrix/test_matrix.py index 3952abc..34bf199 100644 --- a/zulip/integrations/bridge_with_matrix/test_matrix.py +++ b/zulip/integrations/bridge_with_matrix/test_matrix.py @@ -18,7 +18,7 @@ sample_config_path = "matrix_test.conf" sample_config_text = """[matrix] host = https://matrix.org -username = @username:matrix.org +mxid = @username:matrix.org password = password room_id = #zulip:matrix.org