-
-
Notifications
You must be signed in to change notification settings - Fork 180
fix: don't remove timeouts when a member leaves a server #409
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solution lgtm!
Could I ask for at least one test that ensures the database model is handled correctly? Specifically, >create member, >add timeout, >kick member, >create member, (check timeout still exists). Thinking about potentially catching issues if we migrate between databases and this logic is lost.
No need to do testing with rocket, a small database test next to the model would suffice. Example use of test harness if you haven't used database_test!
yet: https://github.com/revoltchat/backend/blob/main/crates/core/database/src/models/bots/model.rs#L170
/// Insert a new server member into the database | ||
async fn insert_member(&self, member: &Member) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, I think we should change the comment / rename the function here.
Specifically, something such as insert_or_merge_member
, with the comment Insert a new server member (or use the existing member if one is found)
let member = server_members.get_mut(id); | ||
if let Some(member) = member { | ||
if member.in_timeout() { | ||
panic!("Soft deletion is not implemented.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing impl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impl not possible without modifying the member object since the reference db uses members directly.
let mut server_members = self.server_members.lock().await; | ||
if server_members.remove(id).is_some() { | ||
Ok(()) | ||
} else { | ||
Err(create_error!(NotFound)) | ||
} | ||
} | ||
|
||
async fn remove_dangling_members(&self) -> Result<()> { | ||
todo!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing impl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impl not possible without modifying the member object since the reference db uses members directly.
Members with timeouts are now persisted until they rejoin or the timeout expires. Members who have left do not show up in API payloads.
Please make sure to check the following tasks before opening and submitting a PR