Merge branch 'client-fix-minor-olm-bugs' into 'master'
[Client] Minor olm fixes See merge request famedly/famedlysdk!202
This commit is contained in:
commit
6f6171cff1
|
@ -1552,7 +1552,13 @@ class Client {
|
||||||
if (existingSessions != null) {
|
if (existingSessions != null) {
|
||||||
for (olm.Session session in existingSessions) {
|
for (olm.Session session in existingSessions) {
|
||||||
if ((type == 0 && session.matches_inbound(body) == 1) || type == 1) {
|
if ((type == 0 && session.matches_inbound(body) == 1) || type == 1) {
|
||||||
|
try {
|
||||||
plaintext = session.decrypt(type, body);
|
plaintext = session.decrypt(type, body);
|
||||||
|
storeOlmSession(senderKey, session);
|
||||||
|
break;
|
||||||
|
} catch (_) {
|
||||||
|
plaintext = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1565,8 +1571,8 @@ class Client {
|
||||||
newSession.create_inbound_from(_olmAccount, senderKey, body);
|
newSession.create_inbound_from(_olmAccount, senderKey, body);
|
||||||
_olmAccount.remove_one_time_keys(newSession);
|
_olmAccount.remove_one_time_keys(newSession);
|
||||||
storeAPI?.storeClient();
|
storeAPI?.storeClient();
|
||||||
storeOlmSession(senderKey, newSession);
|
|
||||||
plaintext = newSession.decrypt(type, body);
|
plaintext = newSession.decrypt(type, body);
|
||||||
|
storeOlmSession(senderKey, newSession);
|
||||||
}
|
}
|
||||||
final Map<String, dynamic> plainContent = json.decode(plaintext);
|
final Map<String, dynamic> plainContent = json.decode(plaintext);
|
||||||
if (plainContent.containsKey("sender") &&
|
if (plainContent.containsKey("sender") &&
|
||||||
|
@ -1597,6 +1603,8 @@ class Client {
|
||||||
if (!_olmSessions.containsKey(curve25519IdentityKey)) {
|
if (!_olmSessions.containsKey(curve25519IdentityKey)) {
|
||||||
_olmSessions[curve25519IdentityKey] = [];
|
_olmSessions[curve25519IdentityKey] = [];
|
||||||
}
|
}
|
||||||
|
_olmSessions[curve25519IdentityKey]
|
||||||
|
.removeWhere((olm.Session s) => s.session_id() == session.session_id());
|
||||||
_olmSessions[curve25519IdentityKey].add(session);
|
_olmSessions[curve25519IdentityKey].add(session);
|
||||||
Map<String, List<String>> pickleMap = {};
|
Map<String, List<String>> pickleMap = {};
|
||||||
for (var entry in olmSessions.entries) {
|
for (var entry in olmSessions.entries) {
|
||||||
|
|
|
@ -505,7 +505,9 @@ class Room {
|
||||||
Future<String> sendEvent(Map<String, dynamic> content,
|
Future<String> sendEvent(Map<String, dynamic> content,
|
||||||
{String txid, Event inReplyTo}) async {
|
{String txid, Event inReplyTo}) async {
|
||||||
final String type = "m.room.message";
|
final String type = "m.room.message";
|
||||||
final String sendType = this.encrypted ? "m.room.encrypted" : type;
|
final String sendType = (this.encrypted && client.encryptionEnabled)
|
||||||
|
? "m.room.encrypted"
|
||||||
|
: type;
|
||||||
|
|
||||||
// Create new transaction id
|
// Create new transaction id
|
||||||
String messageID;
|
String messageID;
|
||||||
|
@ -555,7 +557,9 @@ class Room {
|
||||||
final Map<String, dynamic> response = await client.jsonRequest(
|
final Map<String, dynamic> response = await client.jsonRequest(
|
||||||
type: HTTPType.PUT,
|
type: HTTPType.PUT,
|
||||||
action: "/client/r0/rooms/${id}/send/$sendType/$messageID",
|
action: "/client/r0/rooms/${id}/send/$sendType/$messageID",
|
||||||
data: await encryptGroupMessagePayload(content));
|
data: client.encryptionEnabled
|
||||||
|
? await encryptGroupMessagePayload(content)
|
||||||
|
: content);
|
||||||
final String res = response["event_id"];
|
final String res = response["event_id"];
|
||||||
eventUpdate.content["status"] = 1;
|
eventUpdate.content["status"] = 1;
|
||||||
eventUpdate.content["unsigned"] = {"transaction_id": messageID};
|
eventUpdate.content["unsigned"] = {"transaction_id": messageID};
|
||||||
|
|
Loading…
Reference in a new issue