Matrix-EmailBridge
Matrix-EmailBridge copied to clipboard
Avoid duplicated events
Problem
Same events are being consumed after the bot is removed and then added back into the room. This makes impossible to re-add the bot to the same room without first removing old messages.
How to reproduce it
- Invite the bot to a room and configure it
- Run
!leave
command - The bot is removed from the room
- Invite the bot again in the same room
What is expected to happen
- The bot joins and stays in the room
What actually happens
- The bot joins and then immediately leaves the room
Cause
The bot reprocesses all events and as a result it executes !leave
command again, even though it is an old one.
Solution
Use the FileStore
to persist the room state and make use of membership state
and timestamp
to ignore messages that were sent before the bot was invited into the room.
Additionally, avoid reprocessing same events between restarts by storing and using nextBatchToken