Skip to content

Commit

Permalink
Update StoredGroup to use added_by_address
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieobject committed Apr 8, 2024
1 parent 0a1eb1a commit 4f629c2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ where
mls_group.save(provider.key_store())?;

let group_id = mls_group.group_id().to_vec();
let stored_group = StoredGroup::new(group_id.clone(), now_ns(), membership_state);
// EM: Pass in now added by address
let stored_group = StoredGroup::new(group_id.clone(), now_ns(), membership_state, None);
stored_group.store(provider.conn())?;
// EM: Consider passing in added_by_address here.....
Ok(Self::new(client, group_id, stored_group.created_at_ns, None))
Expand All @@ -231,7 +232,8 @@ where
mls_group.save(provider.key_store())?;

let group_id = mls_group.group_id().to_vec();
let to_store = StoredGroup::new(group_id, now_ns(), GroupMembershipState::Pending);
// EM: Store new added_by_address here
let to_store = StoredGroup::new(group_id, now_ns(), GroupMembershipState::Pending, added_by_address.clone());
let stored_group = provider.conn().insert_or_ignore_group(to_store)?;

Ok(Self::new(
Expand Down
6 changes: 3 additions & 3 deletions xmtp_mls/src/storage/encrypted_store/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ impl_store!(StoredGroup, groups);

impl StoredGroup {
/// Create a new [`Purpose::Conversation`] group. This is the default type of group.
pub fn new(id: ID, created_at_ns: i64, membership_state: GroupMembershipState) -> Self {
pub fn new(id: ID, created_at_ns: i64, membership_state: GroupMembershipState, added_by_address: Option<String>) -> Self {
Self {
id,
created_at_ns,
membership_state,
installations_last_checked: 0,
purpose: Purpose::Conversation,
added_by_address: None,
added_by_address,
}
}

Expand Down Expand Up @@ -253,7 +253,7 @@ pub(crate) mod tests {
let id = rand_vec();
let created_at_ns = now_ns();
let membership_state = state.unwrap_or(GroupMembershipState::Allowed);
StoredGroup::new(id, created_at_ns, membership_state)
StoredGroup::new(id, created_at_ns, membership_state, None)
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/storage/encrypted_store/group_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ mod tests {
};

fn insert_group(conn: &DbConnection, group_id: Vec<u8>) {
let group = StoredGroup::new(group_id, 100, GroupMembershipState::Allowed);
let group = StoredGroup::new(group_id, 100, GroupMembershipState::Allowed, None);
group.store(conn).unwrap();
}

Expand Down

0 comments on commit 4f629c2

Please sign in to comment.