From 21dee5e38e9cbcecc19fee6c908c4f75e92ee781 Mon Sep 17 00:00:00 2001 From: Krombel Date: Sat, 28 Oct 2017 07:34:53 +0200 Subject: [PATCH] remove obsolete webclient as requested in #1527 --- synapse/app/homeserver.py | 46 ++++++---------------------------- synapse/config/server.py | 16 ++---------- synapse/python_dependencies.py | 3 --- synapse/server.py | 1 - 4 files changed, 9 insertions(+), 57 deletions(-) diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 3adf72e14139..c85e0145942a 100755 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -34,8 +34,7 @@ from synapse.http.site import SynapseSite from synapse.metrics import register_memory_metrics from synapse.metrics.resource import METRICS_PREFIX, MetricsResource -from synapse.python_dependencies import CONDITIONAL_REQUIREMENTS, \ - check_requirements +from synapse.python_dependencies import check_requirements from synapse.replication.tcp.resource import ReplicationStreamProtocolFactory from synapse.rest import ClientRestResource from synapse.rest.key.v1.server_key_resource import LocalKey @@ -56,6 +55,7 @@ from twisted.web.resource import EncodingResourceWrapper, Resource from twisted.web.server import GzipEncoderFactory from twisted.web.static import File +from twisted.web.util import Redirect logger = logging.getLogger("synapse.app.homeserver") @@ -64,36 +64,6 @@ def gz_wrap(r): return EncodingResourceWrapper(r, [GzipEncoderFactory()]) -def build_resource_for_web_client(hs): - webclient_path = hs.get_config().web_client_location - if not webclient_path: - try: - import syweb - except ImportError: - quit_with_error( - "Could not find a webclient.\n\n" - "Please either install the matrix-angular-sdk or configure\n" - "the location of the source to serve via the configuration\n" - "option `web_client_location`\n\n" - "To install the `matrix-angular-sdk` via pip, run:\n\n" - " pip install '%(dep)s'\n" - "\n" - "You can also disable hosting of the webclient via the\n" - "configuration option `web_client`\n" - % {"dep": CONDITIONAL_REQUIREMENTS["web_client"].keys()[0]} - ) - syweb_path = os.path.dirname(syweb.__file__) - webclient_path = os.path.join(syweb_path, "webclient") - # GZip is disabled here due to - # https://twistedmatrix.com/trac/ticket/7678 - # (It can stay enabled for the API resources: they call - # write() with the whole body and then finish() straight - # after and so do not trigger the bug. - # GzipFile was removed in commit 184ba09 - # return GzipFile(webclient_path) # TODO configurable? - return File(webclient_path) # TODO configurable? - - class SynapseHomeServer(HomeServer): def _listener_http(self, config, listener_config): port = listener_config["port"] @@ -148,16 +118,14 @@ def _listener_http(self, config, listener_config): SERVER_KEY_V2_PREFIX: KeyApiV2Resource(self), }) - if name == "webclient": - resources[WEB_CLIENT_PREFIX] = build_resource_for_web_client(self) - if name == "metrics" and self.get_config().enable_metrics: resources[METRICS_PREFIX] = MetricsResource(self) - if WEB_CLIENT_PREFIX in resources: - root_resource = RootRedirect(WEB_CLIENT_PREFIX) - else: - root_resource = Resource() + # TODO: which URL should be used= + resources[WEB_CLIENT_PREFIX] = Redirect( + "https://matrix.to/?hs=" + config.server_name + ) + root_resource = resources[WEB_CLIENT_PREFIX] root_resource = create_resource_tree(resources, root_resource) diff --git a/synapse/config/server.py b/synapse/config/server.py index b66993dab9ad..76c2d3326ed1 100644 --- a/synapse/config/server.py +++ b/synapse/config/server.py @@ -22,8 +22,6 @@ class ServerConfig(Config): def read_config(self, config): self.server_name = config["server_name"] self.pid_file = self.abspath(config.get("pid_file")) - self.web_client = config["web_client"] - self.web_client_location = config.get("web_client_location", None) self.soft_file_limit = config["soft_file_limit"] self.daemonize = config.get("daemonize") self.print_pidfile = config.get("print_pidfile") @@ -73,7 +71,7 @@ def read_config(self, config): bind_host = config.get("bind_host", "") gzip_responses = config.get("gzip_responses", True) - names = ["client", "webclient"] if self.web_client else ["client"] + names = ["client"] self.listeners.append({ "port": bind_port, @@ -176,15 +174,6 @@ def default_config(self, server_name, **kwargs): # # cpu_affinity: 0xFFFFFFFF - # Whether to serve a web client from the HTTP/HTTPS root resource. - web_client: True - - # The root directory to server for the above web client. - # If left undefined, synapse will serve the matrix-angular-sdk web client. - # Make sure matrix-angular-sdk is installed with pip if web_client is True - # and web_client_location is undefined - # web_client_location: "/path/to/web/root" - # The public-facing base URL for the client API (not including _matrix/...) # public_baseurl: https://example.com:8448/ @@ -237,7 +226,6 @@ def default_config(self, server_name, **kwargs): # List of resources to host on this listener. names: - client # The client-server APIs, both v1 and v2 - - webclient # The bundled webclient. # Should synapse compress HTTP responses to clients that support it? # This should be disabled if running synapse behind a load balancer @@ -257,7 +245,7 @@ def default_config(self, server_name, **kwargs): x_forwarded: false resources: - - names: [client, webclient] + - names: [client] compress: true - names: [federation] compress: false diff --git a/synapse/python_dependencies.py b/synapse/python_dependencies.py index 7052333c1966..4bd38c8523b4 100644 --- a/synapse/python_dependencies.py +++ b/synapse/python_dependencies.py @@ -42,9 +42,6 @@ "phonenumbers>=8.2.0": ["phonenumbers"], } CONDITIONAL_REQUIREMENTS = { - "web_client": { - "matrix_angular_sdk>=0.6.8": ["syweb>=0.6.8"], - }, "preview_url": { "netaddr>=0.7.18": ["netaddr"], }, diff --git a/synapse/server.py b/synapse/server.py index 10e3e9a4f1ba..9252ecce77c2 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -122,7 +122,6 @@ def build_DEPENDENCY(self) 'client_resource', 'resource_for_federation', 'resource_for_static_content', - 'resource_for_web_client', 'resource_for_content_repo', 'resource_for_server_key', 'resource_for_server_key_v2',