Skip to content

Commit

Permalink
add purpose field to mls group
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Oct 29, 2024
1 parent a59284a commit ee9567c
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 22 deletions.
1 change: 1 addition & 0 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,7 @@ impl FfiConversation {
self.inner.client.clone(),
self.id(),
self.inner.created_at_ns,
self.inner.purpose,
move |message| match message {
Ok(m) => message_callback.on_message(m.into()),
Err(e) => message_callback.on_error(e.into()),
Expand Down
44 changes: 42 additions & 2 deletions bindings_node/src/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use xmtp_mls::{
members::PermissionLevel,
MlsGroup, UpdateAdminListType,
},
storage::group_message::MsgQueryArgs,
storage::{group::Purpose, group_message::MsgQueryArgs},
};
use xmtp_proto::xmtp::mls::message_contents::EncodedContent;

Expand Down Expand Up @@ -73,6 +73,7 @@ pub struct NapiGroup {
inner_client: Arc<RustXmtpClient>,
group_id: Vec<u8>,
created_at_ns: i64,
purpose: Purpose,
}

impl From<MlsGroup<RustXmtpClient>> for NapiGroup {
Expand All @@ -81,17 +82,24 @@ impl From<MlsGroup<RustXmtpClient>> for NapiGroup {
group_id: mls_group.group_id,
created_at_ns: mls_group.created_at_ns,
inner_client: mls_group.client,
purpose: mls_group.purpose,
}
}
}

#[napi]
impl NapiGroup {
pub fn new(inner_client: Arc<RustXmtpClient>, group_id: Vec<u8>, created_at_ns: i64) -> Self {
pub fn new(
inner_client: Arc<RustXmtpClient>,
group_id: Vec<u8>,
created_at_ns: i64,
purpose: Purpose,
) -> Self {
Self {
inner_client,
group_id,
created_at_ns,
purpose,
}
}

Expand All @@ -107,6 +115,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let message_id = group
Expand All @@ -124,6 +133,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let id = group
Expand All @@ -140,6 +150,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);
group.publish_messages().await.map_err(ErrorWrapper::from)?;
Ok(())
Expand All @@ -151,6 +162,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group.sync().await.map_err(ErrorWrapper::from)?;
Expand All @@ -174,6 +186,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let delivery_status = opts.delivery_status.map(|status| status.into());
Expand Down Expand Up @@ -203,6 +216,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);
let envelope_bytes: Vec<u8> = envelope_bytes.deref().to_vec();
let message = group
Expand All @@ -219,6 +233,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let members: Vec<NapiGroupMember> = group
Expand Down Expand Up @@ -252,6 +267,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let admin_list = group
Expand All @@ -267,6 +283,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let super_admin_list = group
Expand Down Expand Up @@ -294,6 +311,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group
Expand All @@ -310,6 +328,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);
group
.update_admin_list(UpdateAdminListType::Add, inbox_id)
Expand All @@ -325,6 +344,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);
group
.update_admin_list(UpdateAdminListType::Remove, inbox_id)
Expand All @@ -340,6 +360,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);
group
.update_admin_list(UpdateAdminListType::AddSuper, inbox_id)
Expand All @@ -355,6 +376,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);
group
.update_admin_list(UpdateAdminListType::RemoveSuper, inbox_id)
Expand All @@ -370,6 +392,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let permissions = group.permissions().map_err(ErrorWrapper::from)?;
Expand All @@ -383,6 +406,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group
Expand All @@ -399,6 +423,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group
Expand All @@ -415,6 +440,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group
Expand All @@ -431,6 +457,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group
Expand All @@ -447,6 +474,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let group_name = group
Expand All @@ -462,6 +490,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group
Expand All @@ -478,6 +507,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let group_image_url_square = group
Expand All @@ -493,6 +523,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group
Expand All @@ -509,6 +540,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let group_description = group
Expand All @@ -524,6 +556,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group
Expand All @@ -540,6 +573,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let group_pinned_frame_url = group
Expand All @@ -557,6 +591,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
move |message| {
tsfn.call(
message
Expand All @@ -582,6 +617,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

Ok(
Expand All @@ -597,6 +633,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

Ok(group.added_by_inbox_id().map_err(ErrorWrapper::from)?)
Expand All @@ -608,6 +645,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let metadata = group
Expand All @@ -623,6 +661,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

let state = group.consent_state().map_err(ErrorWrapper::from)?;
Expand All @@ -636,6 +675,7 @@ impl NapiGroup {
self.inner_client.clone(),
self.group_id.clone(),
self.created_at_ns,
self.purpose,
);

group
Expand Down
3 changes: 3 additions & 0 deletions bindings_wasm/src/conversations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl WasmConversations {
self.inner_client.clone(),
convo.group_id,
convo.created_at_ns,
convo.purpose,
);

Ok(out)
Expand All @@ -149,6 +150,7 @@ impl WasmConversations {
self.inner_client.clone(),
group.group_id,
group.created_at_ns,
group.purpose,
))
}

Expand Down Expand Up @@ -203,6 +205,7 @@ impl WasmConversations {
self.inner_client.clone(),
group.group_id,
group.created_at_ns,
group.purpose,
))
})
.collect();
Expand Down
Loading

0 comments on commit ee9567c

Please sign in to comment.