From d1cbad388fc42d483e0e3b107620852f359d2cc8 Mon Sep 17 00:00:00 2001 From: Sean Quah <8349537+squahtx@users.noreply.github.com> Date: Fri, 1 Oct 2021 17:22:13 +0100 Subject: [PATCH 1/2] Fix error in `get_user_ip_and_agents` when fetching from the database (#10968) --- changelog.d/10968.bugfix | 1 + synapse/storage/databases/main/client_ips.py | 4 +-- tests/storage/test_client_ips.py | 34 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 changelog.d/10968.bugfix diff --git a/changelog.d/10968.bugfix b/changelog.d/10968.bugfix new file mode 100644 index 0000000000..76624ed73c --- /dev/null +++ b/changelog.d/10968.bugfix @@ -0,0 +1 @@ +Fix `/admin/whois/{user_id}` endpoint, which was broken in v1.44.0rc1. diff --git a/synapse/storage/databases/main/client_ips.py b/synapse/storage/databases/main/client_ips.py index 7e33ae578c..cc192f5c87 100644 --- a/synapse/storage/databases/main/client_ips.py +++ b/synapse/storage/databases/main/client_ips.py @@ -591,8 +591,8 @@ class ClientIpStore(ClientIpWorkerStore): ) results.update( - ((row["access_token"], row["ip"]), (row["user_agent"], row["last_seen"])) - for row in rows + ((access_token, ip), (user_agent, last_seen)) + for access_token, ip, user_agent, last_seen in rows ) return [ { diff --git a/tests/storage/test_client_ips.py b/tests/storage/test_client_ips.py index 1c2df54ecc..3cc8038f1e 100644 --- a/tests/storage/test_client_ips.py +++ b/tests/storage/test_client_ips.py @@ -15,9 +15,12 @@ from unittest.mock import Mock +from parameterized import parameterized + import synapse.rest.admin from synapse.http.site import XForwardedForRequest from synapse.rest.client import login +from synapse.types import UserID from tests import unittest from tests.server import make_request @@ -143,6 +146,37 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase): ], ) + @parameterized.expand([(False,), (True,)]) + def test_get_user_ip_and_agents(self, after_persisting: bool): + """Test `get_user_ip_and_agents` for persisted and unpersisted data""" + self.reactor.advance(12345678) + + user_id = "@user:id" + user = UserID.from_string(user_id) + + # Insert a user IP + self.get_success( + self.store.insert_client_ip( + user_id, "access_token", "ip", "user_agent", "MY_DEVICE" + ) + ) + + if after_persisting: + # Trigger the storage loop + self.reactor.advance(10) + + self.assertEqual( + self.get_success(self.store.get_user_ip_and_agents(user)), + [ + { + "access_token": "access_token", + "ip": "ip", + "user_agent": "user_agent", + "last_seen": 12345678000, + }, + ], + ) + @override_config({"limit_usage_by_mau": False, "max_mau_value": 50}) def test_disabled_monthly_active_user(self): user_id = "@user:server" From 2d2c6a41fe69d4dab82a773bbffc52df95b6b542 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Mon, 4 Oct 2021 14:57:40 +0100 Subject: [PATCH 2/2] 1.44.0rc3 --- CHANGES.md | 10 ++++++++++ changelog.d/10933.bugfix | 1 - changelog.d/10968.bugfix | 1 - debian/changelog | 6 ++++++ synapse/__init__.py | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) delete mode 100644 changelog.d/10933.bugfix delete mode 100644 changelog.d/10968.bugfix diff --git a/CHANGES.md b/CHANGES.md index 59ff967633..6c2728d407 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,13 @@ +Synapse 1.44.0rc3 (2021-10-04) +============================== + +Bugfixes +-------- + +- Fix a bug introduced in Synapse v1.40.0 where changing a user's display name or avatar in a restricted room would cause an authentication error. ([\#10933](https://github.com/matrix-org/synapse/issues/10933)) +- Fix `/admin/whois/{user_id}` endpoint, which was broken in v1.44.0rc1. ([\#10968](https://github.com/matrix-org/synapse/issues/10968)) + + Synapse 1.44.0rc2 (2021-09-30) ============================== diff --git a/changelog.d/10933.bugfix b/changelog.d/10933.bugfix deleted file mode 100644 index e0694fea22..0000000000 --- a/changelog.d/10933.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix a bug introduced in Synapse v1.40.0 where changing a user's display name or avatar in a restricted room would cause an authentication error. diff --git a/changelog.d/10968.bugfix b/changelog.d/10968.bugfix deleted file mode 100644 index 76624ed73c..0000000000 --- a/changelog.d/10968.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix `/admin/whois/{user_id}` endpoint, which was broken in v1.44.0rc1. diff --git a/debian/changelog b/debian/changelog index b08a592780..a0f1bcbdf9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +matrix-synapse-py3 (1.44.0~rc3) stable; urgency=medium + + * New synapse release 1.44.0~rc3. + + -- Synapse Packaging team Mon, 04 Oct 2021 14:57:22 +0100 + matrix-synapse-py3 (1.44.0~rc2) stable; urgency=medium * New synapse release 1.44.0~rc2. diff --git a/synapse/__init__.py b/synapse/__init__.py index 8791c20e26..a9a7b658b7 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -47,7 +47,7 @@ try: except ImportError: pass -__version__ = "1.44.0rc2" +__version__ = "1.44.0rc3" if bool(os.environ.get("SYNAPSE_TEST_PATCH_LOG_CONTEXTS", False)): # We import here so that we don't have to install a bunch of deps when