Skip to content

Avoid duplicated events#53

Open
nicuh wants to merge 7 commits into
JojiiOfficial:masterfrom
nicuh:avoid-duplicates-events
Open

Avoid duplicated events#53
nicuh wants to merge 7 commits into
JojiiOfficial:masterfrom
nicuh:avoid-duplicates-events

Conversation

@nicuh

@nicuh nicuh commented May 7, 2022

Copy link
Copy Markdown

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