Merge branch 'keysharing-feature-send-to-all-users' into 'master'
[Event] Key sharing with all users in a room See merge request famedly/famedlysdk!218
This commit is contained in:
commit
0b5e806cdf
|
@ -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<void> sendToDevice(
|
||||
List<DeviceKeys> deviceKeys, String type, Map<String, dynamic> message,
|
||||
{bool encrypted = true}) async {
|
||||
List<DeviceKeys> deviceKeys,
|
||||
String type,
|
||||
Map<String, dynamic> message, {
|
||||
bool encrypted = true,
|
||||
List<User> 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<String, dynamic>(),
|
||||
};
|
||||
if (deviceKeys.isEmpty) {
|
||||
data["messages"][this.userID] = Map<String, dynamic>();
|
||||
data["messages"][this.userID]["*"] = sendToDeviceMessage;
|
||||
if (toUsers == null) {
|
||||
data["messages"][this.userID] = Map<String, dynamic>();
|
||||
data["messages"][this.userID]["*"] = sendToDeviceMessage;
|
||||
} else {
|
||||
for (User user in toUsers) {
|
||||
data["messages"][user.id] = Map<String, dynamic>();
|
||||
data["messages"][user.id]["*"] = sendToDeviceMessage;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < deviceKeys.length; i++) {
|
||||
DeviceKeys device = deviceKeys[i];
|
||||
|
|
|
@ -399,6 +399,7 @@ class Event {
|
|||
this.content["body"] != DecryptError.UNKNOWN_SESSION) {
|
||||
throw ("Session key not unknown");
|
||||
}
|
||||
final List<User> 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue