diff options
author | Mark Haines <mark.haines@matrix.org> | 2016-08-31 10:38:58 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2016-08-31 10:38:58 +0100 |
commit | 1aa3e1d2874370fbb6fa9f4fd2b8a110d81981fc (patch) | |
tree | bf66d9adf23d6611c3128a9fa936c98e8ddf0da2 /synapse/rest/client/v2_alpha | |
parent | Merge pull request #1049 from matrix-org/erikj/presence_users_in_room (diff) | |
download | synapse-1aa3e1d2874370fbb6fa9f4fd2b8a110d81981fc.tar.xz |
Add a replication stream for direct to device messages
Diffstat (limited to 'synapse/rest/client/v2_alpha')
-rw-r--r-- | synapse/rest/client/v2_alpha/sendtodevice.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/rest/client/v2_alpha/sendtodevice.py b/synapse/rest/client/v2_alpha/sendtodevice.py index 00533741af..7c0991ca55 100644 --- a/synapse/rest/client/v2_alpha/sendtodevice.py +++ b/synapse/rest/client/v2_alpha/sendtodevice.py @@ -40,6 +40,7 @@ class SendToDeviceRestServlet(servlet.RestServlet): self.hs = hs self.auth = hs.get_auth() self.store = hs.get_datastore() + self.notifier = hs.get_notifier() self.is_mine_id = hs.is_mine_id self.txns = HttpTransactionStore() @@ -71,9 +72,14 @@ class SendToDeviceRestServlet(servlet.RestServlet): } for device_id, message_content in by_device.items() } - local_messages[user_id] = messages_by_device + if messages_by_device: + local_messages[user_id] = messages_by_device - yield self.store.add_messages_to_device_inbox(local_messages) + stream_id = yield self.store.add_messages_to_device_inbox(local_messages) + + self.notifier.on_new_event( + "to_device", stream_id, users=local_messages.keys() + ) response = (200, {}) self.txns.store_client_transaction(request, txn_id, response) |