diff options
author | Richard van der Hoff <richard@matrix.org> | 2019-03-13 15:55:37 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2019-03-13 17:21:19 +0000 |
commit | fdcad8eabdf20718d053255555fb27ac190613c4 (patch) | |
tree | f4bcd043bcfaf2dac0b2f578f5920f84ce84dcd7 /synapse/federation/transaction_queue.py | |
parent | declare a ReadReceipt class (diff) | |
download | synapse-fdcad8eabdf20718d053255555fb27ac190613c4.tar.xz |
Move client receipt processing to federation sender worker.
This is mostly a prerequisite for #4730, but also fits with the general theme of "move everything off the master that we possibly can".
Diffstat (limited to 'synapse/federation/transaction_queue.py')
-rw-r--r-- | synapse/federation/transaction_queue.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py index e5e42c647d..288cb5045c 100644 --- a/synapse/federation/transaction_queue.py +++ b/synapse/federation/transaction_queue.py @@ -290,6 +290,41 @@ class TransactionQueue(object): self._attempt_new_transaction(destination) + @defer.inlineCallbacks + def send_read_receipt(self, receipt): + """Send a RR to any other servers in the room + + Args: + receipt (synapse.types.ReadReceipt): receipt to be sent + """ + # Work out which remote servers should be poked and poke them. + domains = yield self.state.get_current_hosts_in_room(receipt.room_id) + domains = [d for d in domains if d != self.server_name] + if not domains: + return + + logger.debug("Sending receipt to: %r", domains) + + content = { + receipt.room_id: { + receipt.receipt_type: { + receipt.user_id: { + "event_ids": receipt.event_ids, + "data": receipt.data, + }, + }, + }, + } + key = (receipt.room_id, receipt.receipt_type, receipt.user_id) + + for domain in domains: + self.build_and_send_edu( + destination=domain, + edu_type="m.receipt", + content=content, + key=key, + ) + @logcontext.preserve_fn # the caller should not yield on this @defer.inlineCallbacks def send_presence(self, states): |