summary refs log tree commit diff
path: root/synapse/server.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-11-21 11:08:08 +0000
committerRichard van der Hoff <richard@matrix.org>2017-11-22 16:19:49 +0000
commite1fd4751de8e96907ea97afaf91525e68ce22227 (patch)
treef7b2374e66930e40e0bf00a96f61e129a931dee4 /synapse/server.py
parentMerge pull request #2700 from matrix-org/rav/worker_docs (diff)
downloadsynapse-e1fd4751de8e96907ea97afaf91525e68ce22227.tar.xz
Build MediaRepositoryResource as a homeserver dependency
This avoids the scenario where we have four different PreviewUrlResources
configured on a single app, each of which have their own caches and cache
clearing jobs.
Diffstat (limited to 'synapse/server.py')
-rw-r--r--synapse/server.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/synapse/server.py b/synapse/server.py
index 4746cc7b6c..853f4647b7 100644
--- a/synapse/server.py
+++ b/synapse/server.py
@@ -60,7 +60,10 @@ from synapse.http.matrixfederationclient import MatrixFederationHttpClient
 from synapse.notifier import Notifier
 from synapse.push.action_generator import ActionGenerator
 from synapse.push.pusherpool import PusherPool
-from synapse.rest.media.v1.media_repository import MediaRepository
+from synapse.rest.media.v1.media_repository import (
+    MediaRepository,
+    MediaRepositoryResource,
+)
 from synapse.state import StateHandler
 from synapse.storage import DataStore
 from synapse.streams.events import EventSources
@@ -121,6 +124,7 @@ class HomeServer(object):
         'http_client_context_factory',
         'simple_http_client',
         'media_repository',
+        'media_repository_resource',
         'federation_transport_client',
         'federation_sender',
         'receipts_handler',
@@ -293,6 +297,11 @@ class HomeServer(object):
             **self.db_config.get("args", {})
         )
 
+    def build_media_repository_resource(self):
+        # build the media repo resource. This indirects through the HomeServer
+        # to ensure that we only have a single instance of
+        return MediaRepositoryResource(self)
+
     def build_media_repository(self):
         return MediaRepository(self)