Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mchenani committed Jan 23, 2025
1 parent de91ebf commit 62e2aae
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
17 changes: 12 additions & 5 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ impl TryFrom<FfiPermissionPolicySet> for PolicySet {
MetadataField::GroupPinnedFrameUrl.to_string(),
policy_set.update_group_pinned_frame_url_policy.try_into()?,
);
// MessageExpirationFromMillis follows the same policy as MessageExpirationMillis
// MessageDisappearFromNS follows the same policy as MessageDisappearInNS
metadata_permissions_map.insert(
MetadataField::MessageDisappearFromNS.to_string(),
policy_set
Expand Down Expand Up @@ -1298,7 +1298,7 @@ impl FfiConversationListItem {
}
}

#[derive(uniffi::Record, Debug)]
#[derive(uniffi::Record, Clone, Debug)]
pub struct FfiConversationMessageDisappearingSettings {
pub from_ns: i64,
pub in_ns: i64,
Expand All @@ -1310,6 +1310,12 @@ impl FfiConversationMessageDisappearingSettings {
}
}

impl From<ConversationMessageDisappearingSettings> for FfiConversationMessageDisappearingSettings {
fn from(value: ConversationMessageDisappearingSettings) -> Self {
FfiConversationMessageDisappearingSettings::new(value.from_ns, value.in_ns)
}
}

impl From<MlsGroup<RustXmtpClient>> for FfiConversation {
fn from(mls_group: MlsGroup<RustXmtpClient>) -> FfiConversation {
FfiConversation { inner: mls_group }
Expand Down Expand Up @@ -1475,8 +1481,7 @@ pub struct FfiCreateGroupOptions {
pub group_description: Option<String>,
pub group_pinned_frame_url: Option<String>,
pub custom_permission_policy_set: Option<FfiPermissionPolicySet>,
pub message_disappear_from_ns: Option<i64>,
pub message_disappear_in_ns: Option<i64>,
pub message_disappearing_settings: Option<FfiConversationMessageDisappearingSettings>,
}

impl FfiCreateGroupOptions {
Expand All @@ -1486,7 +1491,9 @@ impl FfiCreateGroupOptions {
image_url_square: self.group_image_url_square,
description: self.group_description,
pinned_frame_url: self.group_pinned_frame_url,
message_disappearing_settings: None,
message_disappearing_settings: self
.message_disappearing_settings
.map(|settings| settings.into()),
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions bindings_node/src/conversation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ pub struct GroupMetadata {
inner: XmtpGroupMetadata,
}

#[napi]
#[napi(object)]
#[derive(Clone)]
pub struct ConversationMessageDisappearingSettings {
inner: XmtpConversationMessageDisappearingSettings,
#[napi]
pub inner: XmtpConversationMessageDisappearingSettings,
}

#[napi]
Expand All @@ -53,6 +54,12 @@ impl ConversationMessageDisappearingSettings {
}
}

impl From<ConversationMessageDisappearingSettings> for XmtpConversationMessageDisappearingSettings {
fn from(value: ConversationMessageDisappearingSettings) -> Self {
XmtpConversationMessageDisappearingSettings::new(value.inner.from_ns, value.inner.in_ns)
}
}

#[napi]
impl GroupMetadata {
#[napi]
Expand Down
4 changes: 3 additions & 1 deletion bindings_node/src/conversations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ impl CreateGroupOptions {
image_url_square: self.group_image_url_square,
description: self.group_description,
pinned_frame_url: self.group_pinned_frame_url,
message_disappearing_settings: None, //todo: fix mapping,
message_disappearing_settings: self
.message_disappearing_settings
.map(|settings| settings.into()),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/groups/group_mutable_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl fmt::Display for MetadataField {
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq)]
pub struct ConversationMessageDisappearingSettings {
pub from_ns: i64,
pub in_ns: i64,
Expand Down

0 comments on commit 62e2aae

Please sign in to comment.