Fix create_account bug

This commit is contained in:
Astra Logical 2026-07-23 13:45:57 -04:00
parent 22d079f079
commit def53187e8

View file

@ -9,7 +9,7 @@ from keycloak import KeycloakAdmin
from keycloak.exceptions import KeycloakError from keycloak.exceptions import KeycloakError
from mautrix.client import Client from mautrix.client import Client
from mautrix.crypto import OlmMachine from mautrix.crypto import OlmMachine, Account
from mautrix.crypto.store import MemoryCryptoStore from mautrix.crypto.store import MemoryCryptoStore
from mautrix.client.state_store import MemoryStateStore from mautrix.client.state_store import MemoryStateStore
from mautrix.types import ( from mautrix.types import (
@ -429,10 +429,12 @@ async def main():
"device_id": client.device_id "device_id": client.device_id
}, f) }, f)
# Create a new Olm account if one wasn't loaded from the crypto store # Ensure an Olm crypto account exists in the store
if not client.crypto.account: account = await client.crypto.store.get_account(client.mxid)
if not account:
log.info("Creating new Olm account...") log.info("Creating new Olm account...")
await client.crypto.create_account() account = Account.generate()
await client.crypto.store.put_account(account)
# Register Event Handlers # Register Event Handlers
client.add_event_handler(EventType.ROOM_MEMBER, on_invite) client.add_event_handler(EventType.ROOM_MEMBER, on_invite)