From def53187e838614a4abfd797a206f7f036867ed4 Mon Sep 17 00:00:00 2001 From: Astra Logical Date: Thu, 23 Jul 2026 13:45:57 -0400 Subject: [PATCH] Fix create_account bug --- matrix_keycloak_bot.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/matrix_keycloak_bot.py b/matrix_keycloak_bot.py index f58a06f..2b5de61 100644 --- a/matrix_keycloak_bot.py +++ b/matrix_keycloak_bot.py @@ -9,7 +9,7 @@ from keycloak import KeycloakAdmin from keycloak.exceptions import KeycloakError from mautrix.client import Client -from mautrix.crypto import OlmMachine +from mautrix.crypto import OlmMachine, Account from mautrix.crypto.store import MemoryCryptoStore from mautrix.client.state_store import MemoryStateStore from mautrix.types import ( @@ -429,10 +429,12 @@ async def main(): "device_id": client.device_id }, f) - # Create a new Olm account if one wasn't loaded from the crypto store - if not client.crypto.account: + # Ensure an Olm crypto account exists in the store + account = await client.crypto.store.get_account(client.mxid) + if not 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 client.add_event_handler(EventType.ROOM_MEMBER, on_invite)