Upload E2E keys to server if needed

This commit is contained in:
miruka 2019-05-06 23:08:36 -04:00
parent 15da828c70
commit 5ff82471fc
2 changed files with 18 additions and 0 deletions

View File

@ -37,6 +37,7 @@
- Status message and presence
- Client improvements
- Initial sync filter and lazy load, see weechat-matrix `_handle_login()`
- HTTP/2
- `retry_after_ms` when rate-limited
- Direct chats category

View File

@ -87,6 +87,10 @@ class Client(QObject):
def login(self, password: str, device_name: str = "") -> "Client":
response = self.net.talk(self.nio.login, password, device_name)
self.nio_sync.receive_response(response)
if not self.nio.olm_account_shared:
self._keys_upload()
return self
@ -97,9 +101,19 @@ class Client(QObject):
response = nio.LoginResponse(user_id, device_id, token)
self.nio.receive_response(response)
self.nio_sync.receive_response(response)
if not self.nio.olm_account_shared:
self._keys_upload()
return self
@futurize(pyqt=False)
def _keys_upload(self) -> None:
print("uploading key")
self.net.talk(self.nio.keys_upload)
@pyqtSlot(result="QVariant")
@futurize()
def logout(self) -> "Client":
@ -127,6 +141,9 @@ class Client(QObject):
def _on_sync(self, response: nio.SyncResponse) -> None:
self.nio.receive_response(response)
if self.nio.should_upload_keys:
self._keys_upload()
for room_id, room_info in response.rooms.invite.items():
for ev in room_info.invite_state:
member_ev = isinstance(ev, nio.InviteMemberEvent)