diff --git a/lib/src/client.dart b/lib/src/client.dart index e7ad2e1..50ef0be 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1708,8 +1708,12 @@ class Client { /// Sends an encrypted [message] of this [type] to these [deviceKeys]. To send /// the request to all devices of the current user, pass an empty list to [deviceKeys]. Future sendToDevice( - List deviceKeys, String type, Map message, - {bool encrypted = true}) async { + List deviceKeys, + String type, + Map message, { + bool encrypted = true, + List toUsers, + }) async { if (encrypted && !encryptionEnabled) return; // Don't send this message to blocked devices. if (deviceKeys.isNotEmpty) { @@ -1764,8 +1768,15 @@ class Client { "messages": Map(), }; if (deviceKeys.isEmpty) { - data["messages"][this.userID] = Map(); - data["messages"][this.userID]["*"] = sendToDeviceMessage; + if (toUsers == null) { + data["messages"][this.userID] = Map(); + data["messages"][this.userID]["*"] = sendToDeviceMessage; + } else { + for (User user in toUsers) { + data["messages"][user.id] = Map(); + data["messages"][user.id]["*"] = sendToDeviceMessage; + } + } } else { for (int i = 0; i < deviceKeys.length; i++) { DeviceKeys device = deviceKeys[i]; diff --git a/lib/src/event.dart b/lib/src/event.dart index 1313eb8..0e8a01f 100644 --- a/lib/src/event.dart +++ b/lib/src/event.dart @@ -399,6 +399,7 @@ class Event { this.content["body"] != DecryptError.UNKNOWN_SESSION) { throw ("Session key not unknown"); } + final List users = await room.requestParticipants(); await room.client.sendToDevice( [], "m.room_key_request", @@ -406,7 +407,8 @@ class Event { "action": "request_cancellation", "request_id": base64.encode(utf8.encode(content["session_id"])), "requesting_device_id": room.client.deviceID, - }); + }, + toUsers: users); await room.client.sendToDevice( [], "m.room_key_request", @@ -421,7 +423,8 @@ class Event { "request_id": base64.encode(utf8.encode(content["session_id"])), "requesting_device_id": room.client.deviceID, }, - encrypted: false); + encrypted: false, + toUsers: users); return; } }