~nicoco/matteridge

3fece4f0d105e8f9dd8e1d36c6a009a6e8e455f4 — nicoco 6 months ago 8c866e7
fix: re-login when token expires

I want to believe this time for good.
1 files changed, 5 insertions(+), 1 deletions(-)

M matteridge/session.py
M matteridge/session.py => matteridge/session.py +5 -1
@@ 73,7 73,6 @@ class Session(BaseSession[str, Recipient]):
        self.send_lock = asyncio.Lock()
        f = self.user.registration_form
        self.mm_client = get_client_from_registration_form(f, self.xmpp.cache)
        self.__init_ws()
        self.view_events = dict[str, asyncio.Event]()
        self._ws_task: Optional[asyncio.Task] = None
        self._update_status_task: Optional[asyncio.Task] = None


@@ 140,6 139,7 @@ class Session(BaseSession[str, Recipient]):
                await self.mm_client.login()
            else:
                raise
        self.__init_ws()
        self.contacts.user_legacy_id = (await self.mm_client.me).username
        t1 = self._ws_task = asyncio.create_task(self.ws.connect(self.on_mm_event))
        t2 = self._update_status_task = asyncio.create_task(


@@ 167,6 167,10 @@ class Session(BaseSession[str, Recipient]):
            "You can try to use the re-login command, but you might need "
            "to unregister and then re-register to the gateway."
        )
        if self._ws_task is not None and not self._ws_task.done():
            self._ws_task.cancel()
        if self._update_status_task is not None and not self._update_status_task.done():
            self._update_status_task.cancel()
        self.logged = False
        self.send_gateway_status(
            f"Not connected to {self.user.registration_form.get('url')}.", "dnd"