Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Dec 19, 2024
1 parent 4c72ddc commit 9cefbc5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 3 additions & 12 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use self::{
intents::IntentError,
validated_commit::CommitValidationError,
};
use crate::storage::StorageError;
use crate::storage::{group::DmIdExt, StorageError};
use xmtp_common::time::now_ns;
use xmtp_proto::xmtp::mls::{
api::v1::{
Expand Down Expand Up @@ -1126,17 +1126,8 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
.ok_or(GroupError::GroupNotFound)?;
let inbox_id = self.client.inbox_id();
// drop the "dm:"
let dm_id = &group.dm_id.ok_or(GroupError::GroupNotFound)?[3..];

// If my inbox id is the first half, return the second half, otherwise return first half
let target_inbox = if dm_id[..inbox_id.len()] == *inbox_id {
// + 1 because there is a colon (:)
&dm_id[(inbox_id.len() + 1)..]
} else {
&dm_id[..inbox_id.len()]
};

Ok(target_inbox.to_string())
let dm_id = &group.dm_id.ok_or(GroupError::GroupNotFound)?;
Ok(dm_id.other_inbox_id(inbox_id))
}

/// Find the `consent_state` of the group
Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/storage/encrypted_store/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ impl std::fmt::Display for ConversationType {
}

pub trait DmIdExt {
fn other_inbox_id(&self, other: &str) -> String;
fn other_inbox_id(&self, id: &str) -> String;
}
impl DmIdExt for String {
fn other_inbox_id(&self, id: &str) -> String {
Expand Down

0 comments on commit 9cefbc5

Please sign in to comment.