From 01a5a8b9e3f4ce0b4e2419df5dc3645de0428629 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 24 Aug 2018 16:22:37 +0100 Subject: [PATCH 1/2] Fix checking if service notice room is already tagged This manifested in synapse repeatedly setting the tag for the room --- synapse/server_notices/resource_limits_server_notices.py | 7 +++---- .../server_notices/test_resource_limits_server_notices.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/synapse/server_notices/resource_limits_server_notices.py b/synapse/server_notices/resource_limits_server_notices.py index 893b9001c..5d86114e0 100644 --- a/synapse/server_notices/resource_limits_server_notices.py +++ b/synapse/server_notices/resource_limits_server_notices.py @@ -146,11 +146,10 @@ class ResourceLimitsServerNotices(object): user_id(str): the user in question room_id(str): the server notices room for that user """ - tags = yield self._store.get_tags_for_user(user_id) - server_notices_tags = tags.get(room_id) + tags = yield self._store.get_tags_for_room(user_id, room_id) need_to_set_tag = True - if server_notices_tags: - if server_notices_tags.get(SERVER_NOTICE_ROOM_TAG): + if tags: + if SERVER_NOTICE_ROOM_TAG in tags: # tag already present, nothing to do here need_to_set_tag = False if need_to_set_tag: diff --git a/tests/server_notices/test_resource_limits_server_notices.py b/tests/server_notices/test_resource_limits_server_notices.py index fede3f52a..0ddf4fd50 100644 --- a/tests/server_notices/test_resource_limits_server_notices.py +++ b/tests/server_notices/test_resource_limits_server_notices.py @@ -55,6 +55,7 @@ class TestResourceLimitsServerNotices(unittest.TestCase): returnValue="" ) self._rlsn._store.add_tag_to_room = Mock() + self._rlsn._store.get_tags_for_room = Mock(return_value={}) self.hs.config.admin_uri = "mailto:user@test.com" @defer.inlineCallbacks From 08abe8e13cf0f078c003c38cf5791f947afc4ae7 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 24 Aug 2018 16:24:13 +0100 Subject: [PATCH 2/2] Newsfile --- changelog.d/3756.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/3756.bugfix diff --git a/changelog.d/3756.bugfix b/changelog.d/3756.bugfix new file mode 100644 index 000000000..6a1f83f0c --- /dev/null +++ b/changelog.d/3756.bugfix @@ -0,0 +1 @@ +Fix tagging of server notice rooms