server: Unstuck the group session shared flag.
The group session shared flag could be stuck in a permanent True state if we try to share a group session comming from a key claim response in the case that we have unverified devices.
This commit is contained in:
parent
5062c4cbd6
commit
c400404e3d
1 changed files with 14 additions and 7 deletions
|
@ -48,6 +48,7 @@ from nio import (
|
||||||
SyncResponse,
|
SyncResponse,
|
||||||
PartialSyncResponse,
|
PartialSyncResponse,
|
||||||
ShareGroupSessionResponse,
|
ShareGroupSessionResponse,
|
||||||
|
ShareGroupSessionError,
|
||||||
KeysQueryResponse,
|
KeysQueryResponse,
|
||||||
KeysClaimResponse,
|
KeysClaimResponse,
|
||||||
DevicesResponse,
|
DevicesResponse,
|
||||||
|
@ -838,6 +839,14 @@ class MatrixServer(object):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def share_group_session(self, room_id, ignore_missing_sessions=False):
|
||||||
|
_, request = self.client.share_group_session(
|
||||||
|
room_id,
|
||||||
|
ignore_missing_sessions
|
||||||
|
)
|
||||||
|
self.send(request)
|
||||||
|
self.group_session_shared[room_id] = True
|
||||||
|
|
||||||
def room_send_event(
|
def room_send_event(
|
||||||
self,
|
self,
|
||||||
room_id, # type: str
|
room_id, # type: str
|
||||||
|
@ -856,9 +865,7 @@ class MatrixServer(object):
|
||||||
except GroupEncryptionError:
|
except GroupEncryptionError:
|
||||||
try:
|
try:
|
||||||
if not self.group_session_shared[room_id]:
|
if not self.group_session_shared[room_id]:
|
||||||
_, request = self.client.share_group_session(room_id)
|
self.share_group_session(room_id)
|
||||||
self.group_session_shared[room_id] = True
|
|
||||||
self.send(request)
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
except EncryptionError:
|
except EncryptionError:
|
||||||
|
@ -1282,6 +1289,9 @@ class MatrixServer(object):
|
||||||
self.get_joined_members(self.rooms_with_missing_members.pop())
|
self.get_joined_members(self.rooms_with_missing_members.pop())
|
||||||
elif isinstance(response, RoomSendResponse):
|
elif isinstance(response, RoomSendResponse):
|
||||||
self.handle_own_messages_error(response)
|
self.handle_own_messages_error(response)
|
||||||
|
elif isinstance(response, ShareGroupSessionError):
|
||||||
|
self.group_session_shared[response.room_id] = False
|
||||||
|
self.share_group_session(response.room_id)
|
||||||
|
|
||||||
def handle_response(self, response):
|
def handle_response(self, response):
|
||||||
# type: (Response) -> None
|
# type: (Response) -> None
|
||||||
|
@ -1363,8 +1373,7 @@ class MatrixServer(object):
|
||||||
elif isinstance(response, KeysClaimResponse):
|
elif isinstance(response, KeysClaimResponse):
|
||||||
self.keys_claimed[response.room_id] = False
|
self.keys_claimed[response.room_id] = False
|
||||||
try:
|
try:
|
||||||
self.group_session_shared[response.room_id] = True
|
self.share_group_session(
|
||||||
_, request = self.client.share_group_session(
|
|
||||||
response.room_id,
|
response.room_id,
|
||||||
ignore_missing_sessions=True
|
ignore_missing_sessions=True
|
||||||
)
|
)
|
||||||
|
@ -1375,8 +1384,6 @@ class MatrixServer(object):
|
||||||
self.encryption_queue[response.room_id].clear()
|
self.encryption_queue[response.room_id].clear()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.send(request)
|
|
||||||
|
|
||||||
elif isinstance(response, ShareGroupSessionResponse):
|
elif isinstance(response, ShareGroupSessionResponse):
|
||||||
room_id = response.room_id
|
room_id = response.room_id
|
||||||
self.group_session_shared[response.room_id] = False
|
self.group_session_shared[response.room_id] = False
|
||||||
|
|
Loading…
Add table
Reference in a new issue