Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IAmTomahawkx
Copy link
Member

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

  • I understand and have followed the contribution guide
  • I have tested my changes locally and they are working as intended

@IAmTomahawkx IAmTomahawkx self-assigned this Apr 14, 2025
@insertish insertish moved this to 🆕 Untriaged in Pull Request Overview Apr 14, 2025
@IAmTomahawkx IAmTomahawkx moved this from 🆕 Untriaged to 💬 Awaiting review in Pull Request Overview Apr 14, 2025
@IAmTomahawkx IAmTomahawkx requested a review from insertish April 14, 2025 03:30
@insertish insertish moved this from 💬 Awaiting review to 🆕 Untriaged in Pull Request Overview Apr 14, 2025
@IAmTomahawkx IAmTomahawkx moved this from 🆕 Untriaged to 💬 Awaiting review in Pull Request Overview Apr 14, 2025
Copy link
Member

@insertish insertish left a 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

Comment on lines 16 to 17
/// Insert a new server member into the database
async fn insert_member(&self, member: &Member) -> Result<()> {
Copy link
Member

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.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing impl.

Copy link
Member Author

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!()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing impl.

Copy link
Member Author

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.

@github-project-automation github-project-automation bot moved this from 💬 Awaiting review to 🛑 Changes requested in Pull Request Overview Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🛑 Changes requested
Development

Successfully merging this pull request may close these issues.

2 participants