Skip to content

Commit

Permalink
Merge pull request #1 from xmtp/rich/fetch-full-member
Browse files Browse the repository at this point in the history
We need the `signature_key` of a given leaf node, because XMTP installation identities are based on this key, with the `credential` proving the linkage between this key and XMTP accounts.

Adding a method to expose the full `Member`, similar to the `members()` method above. Would love to just replace `member()`, but imagine this creates backwards compatibility issues.
  • Loading branch information
richardhuaaa authored Nov 9, 2023
2 parents 2d4991b + a3b9c19 commit 89f2cff
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions openmls/src/group/mls_group/membership.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,23 @@ impl MlsGroup {
.leaf(leaf_index)
.map(|leaf| leaf.credential())
}

/// Returns the [`Member`] corresponding to the given
/// leaf index. Returns `None` if the member can not be found in this group.
pub fn member_at(&self, leaf_index: LeafNodeIndex) -> Option<Member> {
self.group
.public_group()
// This will return an error if the member can't be found.
.leaf(leaf_index)
.map(|leaf_node| {
Member::new(
leaf_index,
leaf_node.encryption_key().as_slice().to_vec(),
leaf_node.signature_key().as_slice().to_vec(),
leaf_node.credential().clone(),
)
})
}
}

/// Helper `enum` that classifies the kind of remove operation. This can be used to
Expand Down

0 comments on commit 89f2cff

Please sign in to comment.