diff --git a/matrix_keycloak_bot.py b/matrix_keycloak_bot.py index 7a5f868..9fc81e6 100644 --- a/matrix_keycloak_bot.py +++ b/matrix_keycloak_bot.py @@ -18,6 +18,7 @@ from nio import ( KeyVerificationCancel, ToDeviceError, UnknownToDeviceEvent, + ToDeviceMessage, ) # ------------------------------------------------------------------------------ @@ -155,14 +156,19 @@ async def on_to_device(client: AsyncClient, event): "methods": ["m.sas.v1"], "transaction_id": tx_id, } - resp = await client.to_device( + + # Wrap the event type and dictionary in a ToDeviceMessage object + message = ToDeviceMessage( "m.key.verification.ready", { event.sender: { from_device: ready_content } - }, + } ) + + resp = await client.to_device(message) + if isinstance(resp, ToDeviceError): print(f"Failed to send verification ready: {resp}") else: