From 5730d17ac71cb23b3e9407e1bd591071608d7b19 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Mon, 28 Sep 2020 18:13:00 +0100 Subject: [PATCH] Expose http_client and public_room_list_manager as properties --- synapse/module_api/__init__.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py index 6a7e19eb42..646f09d2bc 100644 --- a/synapse/module_api/__init__.py +++ b/synapse/module_api/__init__.py @@ -48,8 +48,26 @@ class ModuleApi: self._auth = hs.get_auth() self._auth_handler = auth_handler - self.http_client = hs.get_simple_http_client() # type: SimpleHttpClient - self.public_room_list_manager = PublicRoomListManager(hs) + # We expose these as properties below in order to attach a helpful docstring. + self._http_client = hs.get_simple_http_client() # type: SimpleHttpClient + self._public_room_list_manager = PublicRoomListManager(hs) + + @property + def http_client(self): + """Allows making outbound HTTP requests to remote resources. + + An instance of synapse.http.client.SimpleHttpClient + """ + return self._http_client + + @property + def public_room_list_manager(self): + """Allows adding to, removing from and checking the status of rooms in the + public room list. + + An instance of synapse.module_api.PublicRoomListManager + """ + return self._public_room_list_manager def get_user_by_req(self, req, allow_guest=False): """Check the access_token provided for a request