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."
This commit is contained in:
rht 2021-11-02 07:11:33 -04:00 committed by Tim Abbott
parent 59fd4f070a
commit c41ead698f
2 changed files with 5 additions and 5 deletions

View file

@ -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"),
)

View file

@ -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