-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mutable Metadata group name Part 1 (#643)
* Update openmls to point to fork pr * updated protos and related group permissions * added update metadata intent and mutablemetada obj * feat: initial setup for mutable metadata * update openmls ref to commit on xmtp main * remove redundant struct from and to methods when we have TryFrom traits --------- Co-authored-by: cameronvoell <[email protected]>
- Loading branch information
1 parent
fefea98
commit 1331100
Showing
15 changed files
with
2,418 additions
and
1,816 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use openmls::{ | ||
extensions::{Extension, UnknownExtension}, | ||
group::MlsGroup as OpenMlsGroup, | ||
}; | ||
use prost::Message; | ||
use thiserror::Error; | ||
|
||
use xmtp_proto::xmtp::mls::message_contents::GroupMutableMetadataV1 as GroupMutableMetadataProto; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum GroupMutableMetadataError { | ||
#[error("serialization: {0}")] | ||
Serialization(#[from] prost::EncodeError), | ||
#[error("deserialization: {0}")] | ||
Deserialization(#[from] prost::DecodeError), | ||
#[error("missing extension")] | ||
MissingExtension, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct GroupMutableMetadata { | ||
pub group_name: String, | ||
} | ||
|
||
impl GroupMutableMetadata { | ||
pub fn new(group_name: String) -> Self { | ||
Self { | ||
group_name | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<GroupMutableMetadata> for Vec<u8> { | ||
type Error = GroupMutableMetadataError; | ||
|
||
fn try_from(value: GroupMutableMetadata) -> Result<Self, Self::Error> { | ||
let mut buf = Vec::new(); | ||
let proto_val = GroupMutableMetadataProto { | ||
group_name: value.group_name.clone() | ||
}; | ||
proto_val.encode(&mut buf)?; | ||
|
||
Ok(buf) | ||
} | ||
} | ||
|
||
impl TryFrom<&Vec<u8>> for GroupMutableMetadata { | ||
type Error = GroupMutableMetadataError; | ||
|
||
fn try_from(value: &Vec<u8>) -> Result<Self, Self::Error> { | ||
let proto_val = GroupMutableMetadataProto::decode(value.as_slice())?; | ||
Self::from_proto(proto_val) | ||
} | ||
} | ||
|
||
impl TryFrom<GroupMutableMetadataProto> for GroupMutableMetadata { | ||
type Error = GroupMutableMetadataError; | ||
|
||
fn try_from(value: GroupMutableMetadataProto) -> Result<Self, Self::Error> { | ||
Self::new(value.group_name.clone()) | ||
} | ||
} | ||
|
||
pub fn extract_group_mutable_metadata( | ||
group: &OpenMlsGroup, | ||
) -> Result<GroupMutableMetadata, GroupMutableMetadataError> { | ||
todo!() | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
|
||
use super::*; | ||
#[test] | ||
fn test_preconfigured_mutable_metadata() { | ||
// TODO add test here | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.