Add encryption support to standalone mode

This commit is contained in:
Tulir Asokan 2021-11-19 23:58:17 +02:00
parent a699acc049
commit fc516d78b7
5 changed files with 69 additions and 16 deletions

View file

@ -31,21 +31,15 @@ from .db import DBClient
from .matrix import MaubotMatrixClient
try:
from mautrix.crypto import OlmMachine, StateStore as CryptoStateStore, CryptoStore
from mautrix.crypto import OlmMachine, StateStore as CryptoStateStore, PgCryptoStore
from mautrix.util.async_db import Database as AsyncDatabase
class SQLStateStore(BaseSQLStateStore, CryptoStateStore):
pass
except ImportError as e:
OlmMachine = CryptoStateStore = CryptoStore = PickleCryptoStore = None
OlmMachine = CryptoStateStore = PgCryptoStore = AsyncDatabase = None
SQLStateStore = BaseSQLStateStore
try:
from mautrix.util.async_db import Database as AsyncDatabase
from mautrix.crypto import PgCryptoStore
except ImportError:
AsyncDatabase = None
PgCryptoStore = None
if TYPE_CHECKING:
from .instance import PluginInstance
@ -66,7 +60,7 @@ class Client:
db_instance: DBClient
client: MaubotMatrixClient
crypto: Optional['OlmMachine']
crypto_store: Optional['CryptoStore']
crypto_store: Optional['PgCryptoStore']
started: bool
remote_displayname: Optional[str]