8000 Device Sync Tweaks by codabrink · Pull Request #2053 · xmtp/libxmtp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Device Sync Tweaks #2053

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

Merged
merged 8 commits into from
Jun 3, 2025
Merged

Device Sync Tweaks #2053

merged 8 commits into from
Jun 3, 2025

Conversation

codabrink
Copy link
Contributor
@codabrink codabrink commented May 29, 2025

Filter device sync group additions to only include groups active within 90 days and with allowed or unknown consent states in add_new_installation_to_groups method

The add_new_installation_to_groups method in device_sync.rs now filters groups based on activity within the last 90 days and consent states of Allowed or Unknown. The method signature for create_group_with_inbox_ids in client.rs changes to accept any type implementing AsIdRef trait instead of specifically requiring InboxId objects. New test coverage verifies the filtering behavior in tests.rs.

📍Where to Start

Start with the add_new_installation_to_groups method in device_sync.rs to understand the new filtering logic for group selection.

Changes since #2053 opened

  • Modified device sync installation behavior to exclude groups with unknown consent state [f51c1eb]
  • Refactored nanosecond time constants for better organization [f51c1eb]

Macroscope summarized f51c1eb.

@codabrink codabrink force-pushed the coda/ds-tweaks branch 2 times, most recently from e33a024 to 15ef977 Compare May 29, 2025 21:18
@codabrink codabrink marked this pull request as ready for review May 29, 2025 21:18
@codabrink codabrink requested a review from a team as a code owner May 29, 2025 21:18
Copy link
Contributor
@richardhuaaa richardhuaaa left a comment

Choose a reason for hiding this comment

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

Great change and unit test 👍

Just want to make sure we have consensus on the user experience we want before landing, cc @nplasterer

@@ -518,7 +518,7 @@ where

pub async fn create_group_with_inbox_ids(
&self,
inbox_ids: &[InboxId],
inbox_ids: &[impl AsIdRef],
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the idea behind this change?

Copy link
Contributor Author
@codabrink codabrink Jun 2, 2025

Choose a reason for hiding this comment

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

It's so that we have the option to pass in inbox_id as a &str

Before we had to call .to_string() on the .inbox_id() function like so: client.create_group_with_inbox_ids(bo.inbox_id().to_string())

Now the .to_string() is no longer required, and we can just client.create_group_with_inbox_ids(bo.inbox_id())

@@ -278,7 +281,11 @@ where
/// This should be triggered when a new sync group appears,
/// indicating the presence of a new installation.
pub async fn add_new_installation_to_groups(&self) -> Result<(), DeviceSyncError> {
let groups = self.mls_store.find_groups(GroupQueryArgs::default())?;
let groups = self.mls_store.find_groups(GroupQueryArgs {
activity_after_ns: Some(now_ns() - NS_IN_DAY * 90),
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure we want to throw away groups older than 90 days? I can imagine at least some people who would want to keep their historical conversations for record-keeping purposes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ya I think if they are allowed groups we should sync all of them. @rygine has a proposal for a more advanced history transfer that allows users to have optionality of how much they want to preserver or not. But I don't think we need that in this PR.

let groups = self.mls_store.find_groups(GroupQueryArgs::default())?;
let groups = self.mls_store.find_groups(GroupQueryArgs {
activity_after_ns: Some(now_ns() - NS_IN_DAY * 90),
consent_states: Some(vec![ConsentState::Allowed, ConsentState::Unknown]),
Copy link
Contributor
@richardhuaaa richardhuaaa May 30, 2025

Choose a reason for hiding this comment

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

I'm wondering how we would feel about throwing away ConsentState::Unknown? This corresponds to the 'security line' or message requests tab, and is likely to be a backlog of spam conversations, and is likely where we can throw away the most conversations. If the user later goes on to approve the conversation, normal device syncing will probably add the new device anyway (although the message history from before the approval will likely be missing on the new device).

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep aligned. Only add me to my allowed groups for sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor
@richardhuaaa richardhuaaa left a comment

Choose a reason for hiding this comment

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

Just pre-approving for once we get those changes in, LGTM

@codabrink codabrink enabled auto-merge (squash) June 2, 2025 20:56
@codabrink codabrink merged commit 76726f4 into main Jun 3, 2025
11 of 12 checks passed
@codabrink codabrink deleted the coda/ds-tweaks branch June 3, 2025 14:17
let groups = self.mls_store.find_groups(GroupQueryArgs::default())?;
let groups = self.mls_store.find_groups(GroupQueryArgs {
activity_after_ns: Some(now_ns() - NS_IN_DAY * 90),
consent_states: Some(vec![ConsentState::Allowed]),
Copy link
Contributor

Choose a reason for hiding this comment

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

I was just thinking about this a bit more I'm wondering if we are being too restrictive with only Allowed maybe we should also include Unknown... In the case where I have a few conversations that are unknown that I then approve will I still be able to add my own installation to that group. 🤔 @codabrink maybe we should open this up a little to expand to unknown?

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.

3 participants
0