fix(matrix): reset _device_id_unverified at start of connect()

Per review feedback on #53997 from @teknium1: the flag was set True
on failed device_id resolution but never reset, so a same-adapter
reconnect that successfully resolves a real device_id would keep
skipping server-side key verification indefinitely.

Reset now happens at the top of connect(), before resolution runs,
so every connect() attempt starts clean. A repeat failure re-sets
the flag (unchanged behavior); a recovery correctly clears it.

Adds TestDeviceIdRecoveryOnReconnect to cover the transition.
This commit is contained in:
Gary Walker 2026-06-29 09:47:39 +10:00 committed by kshitij
parent 9048457eab
commit 09dbe76955
2 changed files with 120 additions and 0 deletions

View file

@ -1152,6 +1152,7 @@ class MatrixAdapter(BasePlatformAdapter):
async def connect(self, *, is_reconnect: bool = False) -> bool:
"""Connect to the Matrix homeserver and start syncing."""
self._device_id_unverified = False
if self._client is not None:
try:
await self.disconnect()