From 213c98c00a473bac7363e1a728828e0f056550b8 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 19 Mar 2019 16:50:51 +0000 Subject: Add option to disable search room lists This disables both local and remote room list searching. --- synapse/handlers/room_list.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'synapse/handlers/room_list.py') diff --git a/synapse/handlers/room_list.py b/synapse/handlers/room_list.py index afa508d729..ba50c8aa95 100644 --- a/synapse/handlers/room_list.py +++ b/synapse/handlers/room_list.py @@ -44,6 +44,7 @@ EMPTY_THIRD_PARTY_ID = ThirdPartyInstanceID(None, None) class RoomListHandler(BaseHandler): def __init__(self, hs): super(RoomListHandler, self).__init__(hs) + self.config = hs.config self.response_cache = ResponseCache(hs, "room_list") self.remote_response_cache = ResponseCache(hs, "remote_room_list", timeout_ms=30 * 1000) @@ -70,6 +71,12 @@ class RoomListHandler(BaseHandler): "Getting public room list: limit=%r, since=%r, search=%r, network=%r", limit, since_token, bool(search_filter), network_tuple, ) + if not self.config.enable_room_list_search: + return defer.succeed({ + "chunk": [], + "total_room_count_estimate": 0, + }) + if search_filter: # We explicitly don't bother caching searches or requests for # appservice specific lists. @@ -441,6 +448,12 @@ class RoomListHandler(BaseHandler): def get_remote_public_room_list(self, server_name, limit=None, since_token=None, search_filter=None, include_all_networks=False, third_party_instance_id=None,): + if not self.config.enable_room_list_search: + defer.returnValue({ + "chunk": [], + "total_room_count_estimate": 0, + }) + if search_filter: # We currently don't support searching across federation, so we have # to do it manually without pagination -- cgit 1.5.1 From 7529038e66a81d36a71c654f26165a4215d918b3 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 20 Mar 2019 14:25:28 +0000 Subject: Return before we log --- synapse/handlers/room_list.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'synapse/handlers/room_list.py') diff --git a/synapse/handlers/room_list.py b/synapse/handlers/room_list.py index ba50c8aa95..dc54634107 100644 --- a/synapse/handlers/room_list.py +++ b/synapse/handlers/room_list.py @@ -67,16 +67,17 @@ class RoomListHandler(BaseHandler): appservice and network id to use an appservice specific one. Setting to None returns all public rooms across all lists. """ - logger.info( - "Getting public room list: limit=%r, since=%r, search=%r, network=%r", - limit, since_token, bool(search_filter), network_tuple, - ) if not self.config.enable_room_list_search: return defer.succeed({ "chunk": [], "total_room_count_estimate": 0, }) + logger.info( + "Getting public room list: limit=%r, since=%r, search=%r, network=%r", + limit, since_token, bool(search_filter), network_tuple, + ) + if search_filter: # We explicitly don't bother caching searches or requests for # appservice specific lists. -- cgit 1.5.1 From 2c90422146b169cd43df12ab98e4e02ae53243c7 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 20 Mar 2019 14:25:58 +0000 Subject: Pull out config option --- synapse/handlers/room_list.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'synapse/handlers/room_list.py') diff --git a/synapse/handlers/room_list.py b/synapse/handlers/room_list.py index dc54634107..d6c9d56007 100644 --- a/synapse/handlers/room_list.py +++ b/synapse/handlers/room_list.py @@ -44,7 +44,7 @@ EMPTY_THIRD_PARTY_ID = ThirdPartyInstanceID(None, None) class RoomListHandler(BaseHandler): def __init__(self, hs): super(RoomListHandler, self).__init__(hs) - self.config = hs.config + self.enable_room_list_search = hs.config.enable_room_list_search self.response_cache = ResponseCache(hs, "room_list") self.remote_response_cache = ResponseCache(hs, "remote_room_list", timeout_ms=30 * 1000) @@ -67,7 +67,7 @@ class RoomListHandler(BaseHandler): appservice and network id to use an appservice specific one. Setting to None returns all public rooms across all lists. """ - if not self.config.enable_room_list_search: + if not self.enable_room_list_search: return defer.succeed({ "chunk": [], "total_room_count_estimate": 0, @@ -449,7 +449,7 @@ class RoomListHandler(BaseHandler): def get_remote_public_room_list(self, server_name, limit=None, since_token=None, search_filter=None, include_all_networks=False, third_party_instance_id=None,): - if not self.config.enable_room_list_search: + if not self.enable_room_list_search: defer.returnValue({ "chunk": [], "total_room_count_estimate": 0, -- cgit 1.5.1