forked from MirrorHub/synapse
Actually treat this as static content, not random Resources.
This commit is contained in:
parent
22399d3d8f
commit
0696dfd94b
4 changed files with 7 additions and 31 deletions
|
@ -36,7 +36,8 @@ from synapse.http.server_key_resource import LocalKey
|
||||||
from synapse.http.matrixfederationclient import MatrixFederationHttpClient
|
from synapse.http.matrixfederationclient import MatrixFederationHttpClient
|
||||||
from synapse.api.urls import (
|
from synapse.api.urls import (
|
||||||
CLIENT_PREFIX, FEDERATION_PREFIX, WEB_CLIENT_PREFIX, CONTENT_REPO_PREFIX,
|
CLIENT_PREFIX, FEDERATION_PREFIX, WEB_CLIENT_PREFIX, CONTENT_REPO_PREFIX,
|
||||||
SERVER_KEY_PREFIX, MEDIA_PREFIX, CLIENT_V2_ALPHA_PREFIX, APP_SERVICE_PREFIX
|
SERVER_KEY_PREFIX, MEDIA_PREFIX, CLIENT_V2_ALPHA_PREFIX, APP_SERVICE_PREFIX,
|
||||||
|
STATIC_PREFIX
|
||||||
)
|
)
|
||||||
from synapse.config.homeserver import HomeServerConfig
|
from synapse.config.homeserver import HomeServerConfig
|
||||||
from synapse.crypto import context_factory
|
from synapse.crypto import context_factory
|
||||||
|
@ -81,6 +82,9 @@ class SynapseHomeServer(HomeServer):
|
||||||
webclient_path = os.path.join(syweb_path, "webclient")
|
webclient_path = os.path.join(syweb_path, "webclient")
|
||||||
return File(webclient_path) # TODO configurable?
|
return File(webclient_path) # TODO configurable?
|
||||||
|
|
||||||
|
def build_resource_for_static_content(self):
|
||||||
|
return File("static")
|
||||||
|
|
||||||
def build_resource_for_content_repo(self):
|
def build_resource_for_content_repo(self):
|
||||||
return ContentRepoResource(
|
return ContentRepoResource(
|
||||||
self, self.upload_dir, self.auth, self.content_addr
|
self, self.upload_dir, self.auth, self.content_addr
|
||||||
|
@ -124,8 +128,8 @@ class SynapseHomeServer(HomeServer):
|
||||||
(SERVER_KEY_PREFIX, self.get_resource_for_server_key()),
|
(SERVER_KEY_PREFIX, self.get_resource_for_server_key()),
|
||||||
(MEDIA_PREFIX, self.get_resource_for_media_repository()),
|
(MEDIA_PREFIX, self.get_resource_for_media_repository()),
|
||||||
(APP_SERVICE_PREFIX, self.get_resource_for_app_services()),
|
(APP_SERVICE_PREFIX, self.get_resource_for_app_services()),
|
||||||
|
(STATIC_PREFIX, self.get_resource_for_static_content())
|
||||||
]
|
]
|
||||||
desired_tree += self.get_resource_for_client().get_extra_resources(self)
|
|
||||||
|
|
||||||
if web_client:
|
if web_client:
|
||||||
logger.info("Adding the web client.")
|
logger.info("Adding the web client.")
|
||||||
|
|
|
@ -28,14 +28,6 @@ class ClientV1RestResource(JsonResource):
|
||||||
JsonResource.__init__(self, hs)
|
JsonResource.__init__(self, hs)
|
||||||
self.register_servlets(self, hs)
|
self.register_servlets(self, hs)
|
||||||
|
|
||||||
def get_extra_resources(self, hs):
|
|
||||||
# some parts of client v1 need to produce HTML as the output (e.g.
|
|
||||||
# fallback pages) but we can only produce JSON output. In an effort to
|
|
||||||
# keep similar logic close together, we'll call through to any servlet
|
|
||||||
# which requires HTML output.
|
|
||||||
register_resources = register.get_prefixes_and_resources(hs)
|
|
||||||
return register_resources
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def register_servlets(client_resource, hs):
|
def register_servlets(client_resource, hs):
|
||||||
room.register_servlets(hs, client_resource)
|
room.register_servlets(hs, client_resource)
|
||||||
|
|
|
@ -18,12 +18,10 @@ from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.api.errors import SynapseError, Codes
|
from synapse.api.errors import SynapseError, Codes
|
||||||
from synapse.api.constants import LoginType
|
from synapse.api.constants import LoginType
|
||||||
from synapse.api.urls import STATIC_PREFIX
|
|
||||||
from base import ClientV1RestServlet, client_path_pattern
|
from base import ClientV1RestServlet, client_path_pattern
|
||||||
import synapse.util.stringutils as stringutils
|
import synapse.util.stringutils as stringutils
|
||||||
|
|
||||||
from synapse.util.async import run_on_reactor
|
from synapse.util.async import run_on_reactor
|
||||||
from twisted.web.resource import Resource
|
|
||||||
|
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
import hmac
|
import hmac
|
||||||
|
@ -307,16 +305,6 @@ class RegisterRestServlet(ClientV1RestServlet):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class RegisterFallbackResource(Resource):
|
|
||||||
|
|
||||||
def __init__(self, hs):
|
|
||||||
Resource.__init__(self) # Resource is an old-style class :(
|
|
||||||
self.hs = hs
|
|
||||||
|
|
||||||
def render_GET(self, request):
|
|
||||||
return "NOT_YET_IMPLEMENTED"
|
|
||||||
|
|
||||||
|
|
||||||
def _parse_json(request):
|
def _parse_json(request):
|
||||||
try:
|
try:
|
||||||
content = json.loads(request.content.read())
|
content = json.loads(request.content.read())
|
||||||
|
@ -327,14 +315,5 @@ def _parse_json(request):
|
||||||
raise SynapseError(400, "Content not JSON.")
|
raise SynapseError(400, "Content not JSON.")
|
||||||
|
|
||||||
|
|
||||||
def get_prefixes_and_resources(hs):
|
|
||||||
return [
|
|
||||||
(
|
|
||||||
STATIC_PREFIX + "/client/register",
|
|
||||||
RegisterFallbackResource(hs)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def register_servlets(hs, http_server):
|
def register_servlets(hs, http_server):
|
||||||
RegisterRestServlet(hs).register(http_server)
|
RegisterRestServlet(hs).register(http_server)
|
||||||
|
|
|
@ -73,6 +73,7 @@ class BaseHomeServer(object):
|
||||||
'resource_for_client',
|
'resource_for_client',
|
||||||
'resource_for_client_v2_alpha',
|
'resource_for_client_v2_alpha',
|
||||||
'resource_for_federation',
|
'resource_for_federation',
|
||||||
|
'resource_for_static_content',
|
||||||
'resource_for_web_client',
|
'resource_for_web_client',
|
||||||
'resource_for_content_repo',
|
'resource_for_content_repo',
|
||||||
'resource_for_server_key',
|
'resource_for_server_key',
|
||||||
|
|
Loading…
Reference in a new issue