This commit is contained in:
Binesh Bannerjee 2025-08-21 21:24:19 -07:00 committed by GitHub
commit 32f027a0e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 12 additions and 2 deletions

View file

@ -43,6 +43,7 @@ class Maubot(Program):
server: MaubotServer
db: Database
crypto_db: Database | None
crypto_db_pickle_key: str = "mau.crypto"
plugin_postgres_db: PostgresDatabase | None
state_store: PgStateStore
@ -73,6 +74,7 @@ class Maubot(Program):
)
def prepare_db(self) -> None:
self.crypto_db_pickle_key = self.config["crypto_db_pickle_key"]
self.db = Database.create(
self.config["database"],
upgrade_table=upgrade_table,

View file

@ -186,7 +186,9 @@ class Client(DBClient):
def _prepare_crypto(self) -> None:
self.crypto_store = PgCryptoStore(
account_id=self.id, pickle_key="mau.crypto", db=self.maubot.crypto_db
account_id=self.id,
pickle_key=self.maubot.crypto_db_pickle_key,
db=self.maubot.crypto_db,
)
self.crypto = OlmMachine(
self.client,

View file

@ -43,6 +43,7 @@ class Config(BaseFileConfig):
base["crypto_database"] = self["crypto_database.postgres_uri"]
else:
copy("crypto_database")
copy("crypto_db_pickle_key")
copy("plugin_directories.upload")
copy("plugin_directories.load")
copy("plugin_directories.trash")

View file

@ -3,6 +3,7 @@
# SQLite: sqlite:filename.db
# Postgres: postgresql://username:password@hostname/dbname
database: sqlite:maubot.db
crypto_db_pickle_key: mau.crypto
# Separate database URL for the crypto database. "default" means use the same database as above.
crypto_database: default

View file

@ -147,7 +147,9 @@ if device_id and not OlmMachine:
exc_info=crypto_import_error,
)
elif device_id:
crypto_store = PgCryptoStore(account_id=user_id, pickle_key="mau.crypto", db=db)
crypto_store = PgCryptoStore(
account_id=user_id, pickle_key=config["crypto_db_pickle_key"], db=db
)
state_store = PgCryptoStateStore(db)
bot_config = None

View file

@ -47,6 +47,7 @@ class Config(BaseFileConfig):
copy("server.public_url")
copy("database")
copy("database_opts")
copy("crypto_db_pickle_key")
if "plugin_config" in base:
copy("plugin_config")
copy("logging")

View file

@ -43,6 +43,7 @@ server:
# The database for the plugin. Used for plugin data, the sync token and e2ee data (if enabled).
# SQLite and Postgres are supported.
database: sqlite:bot.db
crypto_db_pickle_key: mau.crypto
# Additional arguments for asyncpg.create_pool() or sqlite3.connect()
# https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool