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

Commit

Permalink
Shuffle receipt handler around so that worker apps don't need to load it
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Nov 23, 2016
1 parent ee5e8d7 commit feec718
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion synapse/federation/replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def __init__(self, hs, transport_layer):
self._clock = hs.get_clock()

self.transaction_actions = TransactionActions(self.store)
self._transaction_queue = hs.get_federation_sender()

self.hs = hs

Expand Down
2 changes: 0 additions & 2 deletions synapse/handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from .directory import DirectoryHandler
from .admin import AdminHandler
from .identity import IdentityHandler
from .receipts import ReceiptsHandler
from .search import SearchHandler


Expand Down Expand Up @@ -56,7 +55,6 @@ def __init__(self, hs):
self.profile_handler = ProfileHandler(hs)
self.directory_handler = DirectoryHandler(hs)
self.admin_handler = AdminHandler(hs)
self.receipts_handler = ReceiptsHandler(hs)
self.identity_handler = IdentityHandler(hs)
self.search_handler = SearchHandler(hs)
self.room_context_handler = RoomContextHandler(hs)
1 change: 0 additions & 1 deletion synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def __init__(self, hs):

self.store = hs.get_datastore()
self.replication_layer = hs.get_replication_layer()
self.federation_sender = hs.get_federation_sender()
self.state_handler = hs.get_state_handler()
self.server_name = hs.hostname
self.keyring = hs.get_keyring()
Expand Down
7 changes: 4 additions & 3 deletions synapse/handlers/initial_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,12 @@ def get_presence():

@defer.inlineCallbacks
def get_receipts():
receipts_handler = self.hs.get_handlers().receipts_handler
receipts = yield receipts_handler.get_receipts_for_room(
receipts = yield self.store.get_linearized_receipts_for_room(
room_id,
now_token.receipt_key
to_key=now_token.receipt_key,
)
if not receipts:
receipts = []
defer.returnValue(receipts)

presence, receipts, (messages, token) = yield defer.gatherResults(
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/v2_alpha/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, hs):
super(ReceiptRestServlet, self).__init__()
self.hs = hs
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()

@defer.inlineCallbacks
Expand Down
5 changes: 5 additions & 0 deletions synapse/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from synapse.handlers.typing import TypingHandler
from synapse.handlers.events import EventHandler, EventStreamHandler
from synapse.handlers.initial_sync import InitialSyncHandler
from synapse.handlers.receipts import ReceiptsHandler
from synapse.http.client import SimpleHttpClient, InsecureInterceptableContextFactory
from synapse.http.matrixfederationclient import MatrixFederationHttpClient
from synapse.notifier import Notifier
Expand Down Expand Up @@ -129,6 +130,7 @@ def build_DEPENDENCY(self)
'media_repository',
'federation_transport_client',
'federation_sender',
'receipts_handler',
]

def __init__(self, hostname, **kwargs):
Expand Down Expand Up @@ -281,6 +283,9 @@ def build_federation_sender(self):
else:
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):
return self.get_pusherpool().remove_pusher(app_id, push_key, user_id)

Expand Down
2 changes: 1 addition & 1 deletion tests/replication/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_receipts(self):
room_id = yield self.create_room()
event_id = yield self.send_text_message(room_id, "Hello, World")
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
)
code, body = yield get
Expand Down

0 comments on commit feec718

Please sign in to comment.