From 14d49c51dbbf1222477e076eb4d8d79c0181f901 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 24 Aug 2018 14:44:16 +0100 Subject: [PATCH 1/3] Make content of tag an empty object rather than null --- synapse/server_notices/resource_limits_server_notices.py | 2 +- synapse/server_notices/server_notices_manager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/server_notices/resource_limits_server_notices.py b/synapse/server_notices/resource_limits_server_notices.py index 98495ddbf9..7144dfcbc2 100644 --- a/synapse/server_notices/resource_limits_server_notices.py +++ b/synapse/server_notices/resource_limits_server_notices.py @@ -153,7 +153,7 @@ class ResourceLimitsServerNotices(object): need_to_set_tag = False if need_to_set_tag: yield self._store.add_tag_to_room( - user_id, room_id, SERVER_NOTICE_ROOM_TAG, None + user_id, room_id, SERVER_NOTICE_ROOM_TAG, {} ) @defer.inlineCallbacks diff --git a/synapse/server_notices/server_notices_manager.py b/synapse/server_notices/server_notices_manager.py index 5968104a99..a5e4728859 100644 --- a/synapse/server_notices/server_notices_manager.py +++ b/synapse/server_notices/server_notices_manager.py @@ -154,7 +154,7 @@ class ServerNoticesManager(object): ) room_id = info['room_id'] yield self._store.add_tag_to_room( - user_id, room_id, SERVER_NOTICE_ROOM_TAG, None + user_id, room_id, SERVER_NOTICE_ROOM_TAG, {}, ) logger.info("Created server notices room %s for %s", room_id, user_id) From cdd24449eeec12f869ceca233085f957d8dc7d19 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 24 Aug 2018 14:50:03 +0100 Subject: [PATCH 2/3] Ensure we wake up /sync when we add tag to notice room --- synapse/server_notices/resource_limits_server_notices.py | 7 ++++++- synapse/server_notices/server_notices_manager.py | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/synapse/server_notices/resource_limits_server_notices.py b/synapse/server_notices/resource_limits_server_notices.py index 7144dfcbc2..893b9001cd 100644 --- a/synapse/server_notices/resource_limits_server_notices.py +++ b/synapse/server_notices/resource_limits_server_notices.py @@ -46,6 +46,8 @@ class ResourceLimitsServerNotices(object): self._message_handler = hs.get_message_handler() self._state = hs.get_state_handler() + self._notifier = hs.get_notifier() + @defer.inlineCallbacks def maybe_send_server_notice_to_user(self, user_id): """Check if we need to send a notice to this user, this will be true in @@ -152,9 +154,12 @@ class ResourceLimitsServerNotices(object): # tag already present, nothing to do here need_to_set_tag = False if need_to_set_tag: - yield self._store.add_tag_to_room( + max_id = yield self._store.add_tag_to_room( user_id, room_id, SERVER_NOTICE_ROOM_TAG, {} ) + self._notifier.on_new_event( + "account_data_key", max_id, users=[user_id] + ) @defer.inlineCallbacks def _is_room_currently_blocked(self, room_id): diff --git a/synapse/server_notices/server_notices_manager.py b/synapse/server_notices/server_notices_manager.py index a5e4728859..c5cc6d728e 100644 --- a/synapse/server_notices/server_notices_manager.py +++ b/synapse/server_notices/server_notices_manager.py @@ -39,6 +39,8 @@ class ServerNoticesManager(object): self._event_creation_handler = hs.get_event_creation_handler() self._is_mine_id = hs.is_mine_id + self._notifier = hs.get_notifier() + def is_enabled(self): """Checks if server notices are enabled on this server. @@ -153,9 +155,13 @@ class ServerNoticesManager(object): creator_join_profile=join_profile, ) room_id = info['room_id'] - yield self._store.add_tag_to_room( + + max_id = yield self._store.add_tag_to_room( user_id, room_id, SERVER_NOTICE_ROOM_TAG, {}, ) + self._notifier.on_new_event( + "account_data_key", max_id, users=[user_id] + ) logger.info("Created server notices room %s for %s", room_id, user_id) defer.returnValue(room_id) From 45fc0ead10d211351201d1ff5d02cc2cfc2d7595 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 24 Aug 2018 15:04:29 +0100 Subject: [PATCH 3/3] Newsfile --- changelog.d/3755.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/3755.bugfix diff --git a/changelog.d/3755.bugfix b/changelog.d/3755.bugfix new file mode 100644 index 0000000000..6a1f83f0ce --- /dev/null +++ b/changelog.d/3755.bugfix @@ -0,0 +1 @@ +Fix tagging of server notice rooms