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
|
/// 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].
|
/// the request to all devices of the current user, pass an empty list to [deviceKeys].
|
||||||
Future<void> sendToDevice(
|
Future<void> sendToDevice(
|
||||||
List<DeviceKeys> deviceKeys, String type, Map<String, dynamic> message,
|
List<DeviceKeys> deviceKeys,
|
||||||
{bool encrypted = true}) async {
|
String type,
|
||||||
|
Map<String, dynamic> message, {
|
||||||
|
bool encrypted = true,
|
||||||
|
List<User> toUsers,
|
||||||
|
}) async {
|
||||||
if (encrypted && !encryptionEnabled) return;
|
if (encrypted && !encryptionEnabled) return;
|
||||||
// Don't send this message to blocked devices.
|
// Don't send this message to blocked devices.
|
||||||
if (deviceKeys.isNotEmpty) {
|
if (deviceKeys.isNotEmpty) {
|
||||||
|
@ -1764,8 +1768,15 @@ class Client {
|
||||||
"messages": Map<String, dynamic>(),
|
"messages": Map<String, dynamic>(),
|
||||||
};
|
};
|
||||||
if (deviceKeys.isEmpty) {
|
if (deviceKeys.isEmpty) {
|
||||||
|
if (toUsers == null) {
|
||||||
data["messages"][this.userID] = Map<String, dynamic>();
|
data["messages"][this.userID] = Map<String, dynamic>();
|
||||||
data["messages"][this.userID]["*"] = sendToDeviceMessage;
|
data["messages"][this.userID]["*"] = sendToDeviceMessage;
|
||||||
|
} else {
|
||||||
|
for (User user in toUsers) {
|
||||||
|
data["messages"][user.id] = Map<String, dynamic>();
|
||||||
|
data["messages"][user.id]["*"] = sendToDeviceMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < deviceKeys.length; i++) {
|
for (int i = 0; i < deviceKeys.length; i++) {
|
||||||
DeviceKeys device = deviceKeys[i];
|
DeviceKeys device = deviceKeys[i];
|
||||||
|
|
|
@ -399,6 +399,7 @@ class Event {
|
||||||
this.content["body"] != DecryptError.UNKNOWN_SESSION) {
|
this.content["body"] != DecryptError.UNKNOWN_SESSION) {
|
||||||
throw ("Session key not unknown");
|
throw ("Session key not unknown");
|
||||||
}
|
}
|
||||||
|
final List<User> users = await room.requestParticipants();
|
||||||
await room.client.sendToDevice(
|
await room.client.sendToDevice(
|
||||||
[],
|
[],
|
||||||
"m.room_key_request",
|
"m.room_key_request",
|
||||||
|
@ -406,7 +407,8 @@ class Event {
|
||||||
"action": "request_cancellation",
|
"action": "request_cancellation",
|
||||||
"request_id": base64.encode(utf8.encode(content["session_id"])),
|
"request_id": base64.encode(utf8.encode(content["session_id"])),
|
||||||
"requesting_device_id": room.client.deviceID,
|
"requesting_device_id": room.client.deviceID,
|
||||||
});
|
},
|
||||||
|
toUsers: users);
|
||||||
await room.client.sendToDevice(
|
await room.client.sendToDevice(
|
||||||
[],
|
[],
|
||||||
"m.room_key_request",
|
"m.room_key_request",
|
||||||
|
@ -421,7 +423,8 @@ class Event {
|
||||||
"request_id": base64.encode(utf8.encode(content["session_id"])),
|
"request_id": base64.encode(utf8.encode(content["session_id"])),
|
||||||
"requesting_device_id": room.client.deviceID,
|
"requesting_device_id": room.client.deviceID,
|
||||||
},
|
},
|
||||||
encrypted: false);
|
encrypted: false,
|
||||||
|
toUsers: users);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue