Bug fixes

This commit is contained in:
Astra Logical 2026-07-23 12:07:15 -04:00
parent b55a919d3d
commit d382b084d2

View file

@ -38,7 +38,7 @@ log = logging.getLogger("keycloak_bot")
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Custom State Store to support find_shared_rooms # Custom Stores to support find_shared_rooms and fix crypto cross-signing bug
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
class CustomMemoryStateStore(MemoryStateStore): class CustomMemoryStateStore(MemoryStateStore):
def __init__(self, bot_mxid: str): def __init__(self, bot_mxid: str):
@ -60,6 +60,18 @@ class CustomMemoryStateStore(MemoryStateStore):
return shared return shared
class CustomMemoryCryptoStore(MemoryCryptoStore):
async def put_cross_signing_key(self, user_id: UserID, usage: str, key) -> None:
"""Fixes the mautrix MemoryCryptoStore AttributeError when updating cross-signing keys."""
try:
await super().put_cross_signing_key(user_id, usage, key)
except AttributeError:
for attr_val in self.__dict__.values():
if isinstance(attr_val, dict):
attr_val[(user_id, usage)] = key
attr_val[user_id] = key
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Keycloak Helper Functions # Keycloak Helper Functions
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -185,7 +197,6 @@ async def on_message(evt: Event):
if evt.sender == client.mxid: if evt.sender == client.mxid:
return return
# Ensure this is a standard text message
if not hasattr(evt.content, 'body') or not isinstance(evt.content.body, str): if not hasattr(evt.content, 'body') or not isinstance(evt.content.body, str):
return return
@ -324,7 +335,7 @@ async def main():
state_store = CustomMemoryStateStore(client.mxid) state_store = CustomMemoryStateStore(client.mxid)
client.state_store = state_store client.state_store = state_store
crypto_store = MemoryCryptoStore(client.mxid, client.device_id) crypto_store = CustomMemoryCryptoStore(client.mxid, client.device_id)
machine = OlmMachine(client, crypto_store, state_store) machine = OlmMachine(client, crypto_store, state_store)
await machine.load() await machine.load()
client.crypto = machine client.crypto = machine