anoadragon453 / matrix-reminder-bot

A bot to remind you about stuff. Supports encrypted rooms
Apache License 2.0
51 stars 19 forks source link

Bot reacts to undecryptable messages before receiving the key #69

Open deepbluev7 opened 3 years ago

deepbluev7 commented 3 years ago

Some clients like Nheko and Hydrogen (I think), sometimes send room keys lazily, if they are still querying device lists or claiming one time keys for newly joined users or devices. This means there may be a small period, where a message is undecryptable for the bot. While that does not happen too often, it did happen a few times to me already (maybe because the bot rotated their session or so).

I think it would be reasonable to allow for a grace period, before the bot considers a message to be undecryptable and replies to it.

(I'm filing this here, because it happens to me usually with the reminder bot, but it may be a nio issue or so.)

Bubu commented 3 years ago

I looked through the nio docs and the MegolmEvent says this: https://matrix-nio.readthedocs.io/en/latest/nio.html#nio.events.room_events.MegolmEvent

An undecrypted Megolm event.

MegolmEvents are presented to library users only if the library fails to decrypt the event because of a missing session key.

MegolmEvents can be stored for later use. If a RoomKeyEvent is later on received with a session id that matches the session_id of this event decryption can be retried.

So maybe we can do this already..

Ian2020 commented 2 months ago

I was getting "Unable to decrypt" for all messages sent from a particular Android device (using Element), however msgs from all my other devices were fine. A log out/in on that device solved it.