Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicated events #53

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

nicuh
Copy link

@nicuh nicuh commented May 7, 2022

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

@nicuh nicuh changed the title Avoid duplicates events Avoid duplicated events May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant