encryption: Update for some olm lib API changes.

This commit is contained in:
poljar (Damir Jelić) 2018-06-04 22:34:18 +02:00
parent 87a8c1a5c0
commit 86ae77c38c
2 changed files with 13 additions and 9 deletions

View file

@ -39,10 +39,14 @@ except NameError:
import matrix.globals import matrix.globals
try: try:
from olm.account import Account, OlmAccountError from olm import (
from olm.session import (Session, InboundSession, OutboundSession, Account,
OlmSessionError, OlmPreKeyMessage) OlmAccountError,
from olm.group_session import ( Session,
InboundSession,
OutboundSession,
OlmSessionError,
OlmPreKeyMessage,
InboundGroupSession, InboundGroupSession,
OutboundGroupSession, OutboundGroupSession,
OlmGroupSessionError OlmGroupSessionError
@ -787,7 +791,7 @@ class Olm():
cursor.execute("""update olmsessions set pickle=? cursor.execute("""update olmsessions set pickle=?
where user = ? and session_id = ? and where user = ? and session_id = ? and
device_id = ?""", device_id = ?""",
(session.pickle(), user, session.id(), (session.pickle(), user, session.id,
device_id)) device_id))
self.database.commit() self.database.commit()
@ -800,7 +804,7 @@ class Olm():
for session in session_dict.values(): for session in session_dict.values():
cursor.execute("""update inbound_group_sessions set pickle=? cursor.execute("""update inbound_group_sessions set pickle=?
where room_id = ? and session_id = ?""", where room_id = ? and session_id = ?""",
(session.pickle(), room_id, session.id())) (session.pickle(), room_id, session.id))
self.database.commit() self.database.commit()
cursor.close() cursor.close()
@ -809,7 +813,7 @@ class Olm():
cursor = self.database.cursor() cursor = self.database.cursor()
cursor.execute("insert into olmsessions values(?,?,?,?)", cursor.execute("insert into olmsessions values(?,?,?,?)",
(user, device_id, session.id(), session.pickle())) (user, device_id, session.id, session.pickle()))
self.database.commit() self.database.commit()

View file

@ -556,7 +556,7 @@ class MatrixServer:
def upload_keys(self, device_keys=False, one_time_keys=False): def upload_keys(self, device_keys=False, one_time_keys=False):
keys = self.olm.account.identity_keys() if device_keys else None keys = self.olm.account.identity_keys() if device_keys else None
one_time_keys = (self.olm.account.one_time_keys()["curve25519"] if one_time_keys = (self.olm.account.one_time_keys["curve25519"] if
one_time_keys else None) one_time_keys else None)
message = MatrixKeyUploadMessage(self.client, self.user_id, message = MatrixKeyUploadMessage(self.client, self.user_id,
@ -566,7 +566,7 @@ class MatrixServer:
@encrypt_enabled @encrypt_enabled
def check_one_time_keys(self, key_count): def check_one_time_keys(self, key_count):
max_keys = self.olm.account.max_one_time_keys() max_keys = self.olm.account.max_one_time_keys
key_count = (max_keys / 2) - key_count key_count = (max_keys / 2) - key_count