Shuffle receipt handler around so that worker apps don't need to load it
This commit is contained in:
parent
ee5e8d71ac
commit
feec718265
|
@ -64,7 +64,6 @@ class ReplicationLayer(FederationClient, FederationServer):
|
||||||
self._clock = hs.get_clock()
|
self._clock = hs.get_clock()
|
||||||
|
|
||||||
self.transaction_actions = TransactionActions(self.store)
|
self.transaction_actions = TransactionActions(self.store)
|
||||||
self._transaction_queue = hs.get_federation_sender()
|
|
||||||
|
|
||||||
self.hs = hs
|
self.hs = hs
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ from .profile import ProfileHandler
|
||||||
from .directory import DirectoryHandler
|
from .directory import DirectoryHandler
|
||||||
from .admin import AdminHandler
|
from .admin import AdminHandler
|
||||||
from .identity import IdentityHandler
|
from .identity import IdentityHandler
|
||||||
from .receipts import ReceiptsHandler
|
|
||||||
from .search import SearchHandler
|
from .search import SearchHandler
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +55,6 @@ class Handlers(object):
|
||||||
self.profile_handler = ProfileHandler(hs)
|
self.profile_handler = ProfileHandler(hs)
|
||||||
self.directory_handler = DirectoryHandler(hs)
|
self.directory_handler = DirectoryHandler(hs)
|
||||||
self.admin_handler = AdminHandler(hs)
|
self.admin_handler = AdminHandler(hs)
|
||||||
self.receipts_handler = ReceiptsHandler(hs)
|
|
||||||
self.identity_handler = IdentityHandler(hs)
|
self.identity_handler = IdentityHandler(hs)
|
||||||
self.search_handler = SearchHandler(hs)
|
self.search_handler = SearchHandler(hs)
|
||||||
self.room_context_handler = RoomContextHandler(hs)
|
self.room_context_handler = RoomContextHandler(hs)
|
||||||
|
|
|
@ -71,7 +71,6 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
self.replication_layer = hs.get_replication_layer()
|
self.replication_layer = hs.get_replication_layer()
|
||||||
self.federation_sender = hs.get_federation_sender()
|
|
||||||
self.state_handler = hs.get_state_handler()
|
self.state_handler = hs.get_state_handler()
|
||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
self.keyring = hs.get_keyring()
|
self.keyring = hs.get_keyring()
|
||||||
|
|
|
@ -372,11 +372,12 @@ class InitialSyncHandler(BaseHandler):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_receipts():
|
def get_receipts():
|
||||||
receipts_handler = self.hs.get_handlers().receipts_handler
|
receipts = yield self.store.get_linearized_receipts_for_room(
|
||||||
receipts = yield receipts_handler.get_receipts_for_room(
|
|
||||||
room_id,
|
room_id,
|
||||||
now_token.receipt_key
|
to_key=now_token.receipt_key,
|
||||||
)
|
)
|
||||||
|
if not receipts:
|
||||||
|
receipts = []
|
||||||
defer.returnValue(receipts)
|
defer.returnValue(receipts)
|
||||||
|
|
||||||
presence, receipts, (messages, token) = yield defer.gatherResults(
|
presence, receipts, (messages, token) = yield defer.gatherResults(
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ReceiptRestServlet(RestServlet):
|
||||||
super(ReceiptRestServlet, self).__init__()
|
super(ReceiptRestServlet, self).__init__()
|
||||||
self.hs = hs
|
self.hs = hs
|
||||||
self.auth = hs.get_auth()
|
self.auth = hs.get_auth()
|
||||||
self.receipts_handler = hs.get_handlers().receipts_handler
|
self.receipts_handler = hs.get_receipts_handler()
|
||||||
self.presence_handler = hs.get_presence_handler()
|
self.presence_handler = hs.get_presence_handler()
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
|
@ -47,6 +47,7 @@ from synapse.handlers.sync import SyncHandler
|
||||||
from synapse.handlers.typing import TypingHandler
|
from synapse.handlers.typing import TypingHandler
|
||||||
from synapse.handlers.events import EventHandler, EventStreamHandler
|
from synapse.handlers.events import EventHandler, EventStreamHandler
|
||||||
from synapse.handlers.initial_sync import InitialSyncHandler
|
from synapse.handlers.initial_sync import InitialSyncHandler
|
||||||
|
from synapse.handlers.receipts import ReceiptsHandler
|
||||||
from synapse.http.client import SimpleHttpClient, InsecureInterceptableContextFactory
|
from synapse.http.client import SimpleHttpClient, InsecureInterceptableContextFactory
|
||||||
from synapse.http.matrixfederationclient import MatrixFederationHttpClient
|
from synapse.http.matrixfederationclient import MatrixFederationHttpClient
|
||||||
from synapse.notifier import Notifier
|
from synapse.notifier import Notifier
|
||||||
|
@ -129,6 +130,7 @@ class HomeServer(object):
|
||||||
'media_repository',
|
'media_repository',
|
||||||
'federation_transport_client',
|
'federation_transport_client',
|
||||||
'federation_sender',
|
'federation_sender',
|
||||||
|
'receipts_handler',
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, hostname, **kwargs):
|
def __init__(self, hostname, **kwargs):
|
||||||
|
@ -281,6 +283,9 @@ class HomeServer(object):
|
||||||
else:
|
else:
|
||||||
raise Exception("Workers cannot send federation traffic")
|
raise Exception("Workers cannot send federation traffic")
|
||||||
|
|
||||||
|
def build_receipts_handler(self):
|
||||||
|
return ReceiptsHandler(self)
|
||||||
|
|
||||||
def remove_pusher(self, app_id, push_key, user_id):
|
def remove_pusher(self, app_id, push_key, user_id):
|
||||||
return self.get_pusherpool().remove_pusher(app_id, push_key, user_id)
|
return self.get_pusherpool().remove_pusher(app_id, push_key, user_id)
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ class ReplicationResourceCase(unittest.TestCase):
|
||||||
room_id = yield self.create_room()
|
room_id = yield self.create_room()
|
||||||
event_id = yield self.send_text_message(room_id, "Hello, World")
|
event_id = yield self.send_text_message(room_id, "Hello, World")
|
||||||
get = self.get(receipts="-1")
|
get = self.get(receipts="-1")
|
||||||
yield self.hs.get_handlers().receipts_handler.received_client_receipt(
|
yield self.hs.get_receipts_handler().received_client_receipt(
|
||||||
room_id, "m.read", self.user_id, event_id
|
room_id, "m.read", self.user_id, event_id
|
||||||
)
|
)
|
||||||
code, body = yield get
|
code, body = yield get
|
||||||
|
|
Loading…
Reference in New Issue