diff --git a/lib/crypto/index.js b/lib/crypto/index.js index fbf71f2fb..300e8c56e 100644 --- a/lib/crypto/index.js +++ b/lib/crypto/index.js @@ -105,9 +105,6 @@ function Crypto(baseApis, eventEmitter, sessionStore, userId, deviceId) { } _registerEventHandlers(this, eventEmitter); - - // map from userId -> deviceId -> roomId -> timestamp - this._lastNewDeviceMessageTsByUserDeviceRoom = {}; } function _registerEventHandlers(crypto, eventEmitter) { @@ -962,58 +959,6 @@ Crypto.prototype.decryptEvent = function(event) { alg.decryptEvent(event); }; -/** - * Send a "m.new_device" message to remind it that we exist and are a member - * of a room. - * - * This is rate limited to send a message at most once an hour per desination. - * - * @param {string} userId The ID of the user to ping. - * @param {string?} deviceId The ID of the device to ping. If null, all - * devices. - * @param {string} roomId The ID of the room we want to remind them about. - */ -Crypto.prototype._sendPingToDevice = function(userId, deviceId, roomId) { - if (deviceId === null) { - deviceId = "*"; - } - - var lastMessageTsMap = this._lastNewDeviceMessageTsByUserDeviceRoom; - - var lastTsByDevice = lastMessageTsMap[userId]; - if (!lastTsByDevice) { - lastTsByDevice = lastMessageTsMap[userId] = {}; - } - - var lastTsByRoom = lastTsByDevice[deviceId]; - if (!lastTsByRoom) { - lastTsByRoom = lastTsByDevice[deviceId] = {}; - } - - var lastTs = lastTsByRoom[roomId]; - var timeNowMs = Date.now(); - var oneHourMs = 1000 * 60 * 60; - - if (lastTs !== undefined && lastTs + oneHourMs > timeNowMs) { - // rate-limiting - return; - } - - var content = {}; - content[userId] = {}; - content[userId][deviceId] = { - device_id: this._deviceId, - rooms: [roomId], - }; - - this._baseApis.sendToDevice( - "m.new_device", // OH HAI! - content - ).done(); - - lastTsByRoom[roomId] = timeNowMs; -}; - /** * handle an m.room.encryption event *