From 1bb87fec0cb244bc7bd4886c58d2fdcec5e7b3c7 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 13 Jan 2020 15:24:46 +0000 Subject: Log received 'm.room_key_request' EDUs --- synapse/handlers/devicemessage.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'synapse/handlers') diff --git a/synapse/handlers/devicemessage.py b/synapse/handlers/devicemessage.py index 21ea89d279..4a7b2328c1 100644 --- a/synapse/handlers/devicemessage.py +++ b/synapse/handlers/devicemessage.py @@ -81,10 +81,29 @@ class DeviceMessageHandler(object): } local_messages[user_id] = messages_by_device - # We expect the sending user to send the message to all the devices - # to the user, if they don't then that is potentially suspicious and - # so we log for debugging purposes. - if device_list_debugging_logger.isEnabledFor(logging.INFO): + if ( + device_list_debugging_logger.isEnabledFor(logging.INFO) + and message_type == "m.room_key_request" + ): + # If we get a request to get keys then may mean the recipient + # didn't know about the sender's device (or might just mean + # things are being a bit slow to propogate). + received_devices = set(by_device) + sender_key = list(by_device.values())[0].get("sender_key", "") + device_list_debugging_logger.info( + "Received room_key request direct message (%s, %s) from %s (%s) to %s (%s).", + message_type, + message_id, + sender_user_id, + sender_key, + user_id, + received_devices, + ) + elif device_list_debugging_logger.isEnabledFor(logging.INFO): + # We expect the sending user to send the message to all the devices + # to the user, if they don't then that is potentially suspicious and + # so we log for debugging purposes. + expected_devices = yield self.store.get_devices_by_user(user_id) expected_devices = set(expected_devices) received_devices = set(by_device) -- cgit 1.5.1