From 23f3993bcefa1db62acdcc43688be62354f1cc8b Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sun, 8 Nov 2020 20:27:12 +0000 Subject: [PATCH] Update 'Feature: Room State Management' --- Feature%3A-Room-State-Management.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Feature%3A-Room-State-Management.md b/Feature%3A-Room-State-Management.md index 42cd214..9ca334e 100644 --- a/Feature%3A-Room-State-Management.md +++ b/Feature%3A-Room-State-Management.md @@ -6,9 +6,13 @@ Planning and design of the room state management "feature." ## Bot Changes -Listen to Matrix event for when users enter and leave rooms. This is easily accomplished with the `on_room_member` event. When the bot joins a room for the first time, member events are fired for every member in the room. It seems to sync everything, so you will get a join and leave notification many times, potentially. +Listen to Matrix event for when users enter and leave rooms. This is easily accomplished with the `on_room_member` event. -The bot does not get membership events from other users when leaving a room. Instead, it will get a member event of leaving the room for itself. In that circumstance, it should delete all user information in the database for the room. +* When the bot joins a room for the first time, member events are fired for every member in the room. +* It seems to sync everything, so you will get a join and leave notification many times, potentially. This is problematic for a few reasons. +* **Solution:** The simple solution in the beginning is to ignore any event more than a few seconds old, and then do a full sync of the users in the room when processing the join event. This works until there's a big network slowdown. + +If the bot is kicked or banned, it does not get events for users leaving a room. Instead, it will get a member event of leaving the room for itself. In that circumstance, it should delete all user information in the database for the room. RoomInfo struct is created/updated when the bot joins a room.