Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

remove obsolete webclient #2601

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 9 additions & 36 deletions synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from twisted.web.resource import EncodingResourceWrapper, NoResource
from twisted.web.server import GzipEncoderFactory
from twisted.web.static import File
from twisted.web.util import Redirect

import synapse
import synapse.config.logger
Expand All @@ -54,7 +55,7 @@
from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.metrics.resource import METRICS_PREFIX, MetricsResource
from synapse.module_api import ModuleApi
from synapse.python_dependencies import CONDITIONAL_REQUIREMENTS, check_requirements
from synapse.python_dependencies import check_requirements
from synapse.replication.http import REPLICATION_PREFIX, ReplicationRestResource
from synapse.replication.tcp.resource import ReplicationStreamProtocolFactory
from synapse.rest import ClientRestResource
Expand All @@ -80,36 +81,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):
DATASTORE_CLASS = DataStore

Expand Down Expand Up @@ -138,8 +109,8 @@ def _listener_http(self, config, listener_config):
handler = handler_cls(config, module_api)
resources[path] = AdditionalResource(self, handler.handle_request)

if WEB_CLIENT_PREFIX in resources:
root_resource = RootRedirect(WEB_CLIENT_PREFIX)
if config.redirect_root_to_static:
root_resource = RootRedirect(STATIC_PREFIX)
else:
root_resource = NoResource()

Expand Down Expand Up @@ -185,6 +156,11 @@ def _configure_named_resource(self, name, compress=False):
dict[str, Resource]: map from path to HTTP resource
"""
resources = {}
if name == "webclient":
# redirect old webclients to root
logger.warn("DEPRECATED: Handling of webclient got removed from synapse.")
resources[WEB_CLIENT_PREFIX] = Redirect(STATIC_PREFIX)

if name == "client":
client_resource = ClientRestResource(self)
if compress:
Expand Down Expand Up @@ -242,9 +218,6 @@ def _configure_named_resource(self, name, compress=False):
if name in ["keys", "federation"]:
resources[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(RegistryProxy)

Expand Down
22 changes: 6 additions & 16 deletions synapse/config/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def read_config(self, config):
raise ConfigError(str(e))

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.redirect_root_to_static = config.get("redirect_root_to_static", True)
self.soft_file_limit = config["soft_file_limit"]
self.daemonize = config.get("daemonize")
self.print_pidfile = config.get("print_pidfile")
Expand Down Expand Up @@ -136,16 +135,14 @@ 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"]

self.listeners.append({
"port": bind_port,
"bind_addresses": [bind_host],
"tls": True,
"type": "http",
"resources": [
{
"names": names,
"names": ["client"],
"compress": gzip_responses,
},
{
Expand All @@ -164,7 +161,7 @@ def read_config(self, config):
"type": "http",
"resources": [
{
"names": names,
"names": ["client"],
"compress": gzip_responses,
},
{
Expand Down Expand Up @@ -247,14 +244,8 @@ 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"
# Whether to redirect the root ressource to the static prefix or not
# redirect_root_to_static: True

# The public-facing base URL for the client API (not including _matrix/...)
# public_baseurl: https://example.com:8448/
Expand Down Expand Up @@ -321,7 +312,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
Expand All @@ -348,7 +338,7 @@ def default_config(self, server_name, **kwargs):
x_forwarded: false

resources:
- names: [client, webclient]
- names: [client]
compress: true
- names: [federation]
compress: false
Expand Down
4 changes: 2 additions & 2 deletions synapse/python_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
}

CONDITIONAL_REQUIREMENTS = {
"web_client": {
"matrix_angular_sdk>=0.6.8": ["syweb>=0.6.8"],
"preview_url": {
"netaddr>=0.7.18": ["netaddr"],
},
"email.enable_notifs": {
"Jinja2>=2.8": ["Jinja2>=2.8"],
Expand Down
26 changes: 26 additions & 0 deletions synapse/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<html>
<head>
<title>Synapse is running</title>
<style>
body {
width: 30em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
h1 {
text-align: center;
}
</style>
</head>
<body>
<h1>Synapse is running</h1>
<p>Congratulations!</p>
<p>Your Synapse server is listening on this port and is ready for messages.</p>
<p>To use this matrix-server you'll need a client - e.g. one of
<a href="https://matrix.org/docs/projects/try-matrix-now.html#clients">this list of matrix clients</a>.</p>
<p>You can find (federated) rooms that might be of interesting for you on <br />
<a href="https://view.matrix.org/">view.matrix.org</a>.</p>
<p>Or you just start creating your own rooms with your friends</p>
<p>Welcome to the matrix-universe :)</p>
</body>
</html>