Fix some bugs related to relogin
This commit is contained in:
parent
2800e967b8
commit
80c8aba8f6
@ -1,3 +1,4 @@
|
|||||||
from .plugin_base import Plugin
|
from .plugin_base import Plugin
|
||||||
from .plugin_server import PluginWebApp
|
from .plugin_server import PluginWebApp
|
||||||
from .matrix import MaubotMatrixClient as Client, MaubotMessageEvent as MessageEvent
|
from .matrix import MaubotMatrixClient as Client, MaubotMessageEvent as MessageEvent
|
||||||
|
from .__meta__ import __version__
|
||||||
|
@ -20,7 +20,6 @@ from yarl import URL
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from ..config import get_token
|
|
||||||
from ..cliq import cliq
|
from ..cliq import cliq
|
||||||
|
|
||||||
history_count: int = 10
|
history_count: int = 10
|
||||||
|
@ -110,6 +110,19 @@ class Client:
|
|||||||
self.crypto = OlmMachine(self.client, self.crypto_store, self.global_state_store)
|
self.crypto = OlmMachine(self.client, self.crypto_store, self.global_state_store)
|
||||||
self.client.crypto = self.crypto
|
self.client.crypto = self.crypto
|
||||||
|
|
||||||
|
def _remove_crypto_event_handlers(self) -> None:
|
||||||
|
if not self.crypto:
|
||||||
|
return
|
||||||
|
handlers = [
|
||||||
|
(InternalEventType.DEVICE_OTK_COUNT, self.crypto.handle_otk_count),
|
||||||
|
(InternalEventType.DEVICE_LISTS, self.crypto.handle_device_lists),
|
||||||
|
(EventType.TO_DEVICE_ENCRYPTED, self.crypto.handle_to_device_event),
|
||||||
|
(EventType.ROOM_KEY_REQUEST, self.crypto.handle_room_key_request),
|
||||||
|
(EventType.ROOM_MEMBER, self.crypto.handle_member_event),
|
||||||
|
]
|
||||||
|
for event_type, func in handlers:
|
||||||
|
self.client.remove_event_handler(event_type, func)
|
||||||
|
|
||||||
def _set_sync_ok(self, ok: bool) -> Callable[[Dict[str, Any]], Awaitable[None]]:
|
def _set_sync_ok(self, ok: bool) -> Callable[[Dict[str, Any]], Awaitable[None]]:
|
||||||
async def handler(data: Dict[str, Any]) -> None:
|
async def handler(data: Dict[str, Any]) -> None:
|
||||||
self.sync_ok = ok
|
self.sync_ok = ok
|
||||||
@ -316,6 +329,9 @@ class Client:
|
|||||||
raise ValueError(f"Device ID mismatch: {whoami.device_id}")
|
raise ValueError(f"Device ID mismatch: {whoami.device_id}")
|
||||||
new_client.sync_store = SyncStoreProxy(self.db_instance)
|
new_client.sync_store = SyncStoreProxy(self.db_instance)
|
||||||
self.stop_sync()
|
self.stop_sync()
|
||||||
|
self._remove_crypto_event_handlers()
|
||||||
|
new_client.event_handlers = self.client.event_handlers
|
||||||
|
new_client.global_event_handlers = self.client.global_event_handlers
|
||||||
self.client = new_client
|
self.client = new_client
|
||||||
self.db_instance.homeserver = homeserver
|
self.db_instance.homeserver = homeserver
|
||||||
self.db_instance.access_token = access_token
|
self.db_instance.access_token = access_token
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
mautrix>=0.11,<0.12
|
mautrix>=0.11,<0.13
|
||||||
aiohttp>=3,<4
|
aiohttp>=3,<4
|
||||||
yarl>=1,<2
|
yarl>=1,<2
|
||||||
SQLAlchemy>=1,<1.4
|
SQLAlchemy>=1,<1.4
|
||||||
|
Loading…
Reference in New Issue
Block a user