Skip to content

Commit

Permalink
add content type filtering to bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Dec 19, 2024
1 parent 0a44516 commit 379a28c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,7 @@ pub struct FfiListMessagesOptions {
pub limit: Option<i64>,
pub delivery_status: Option<FfiDeliveryStatus>,
pub direction: Option<FfiDirection>,
pub content_types: Option<Vec<String>>,
}

#[derive(uniffi::Record, Clone, Default)]
Expand Down
5 changes: 5 additions & 0 deletions xmtp_mls/src/storage/encrypted_store/group_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ pub struct MsgQueryArgs {
delivery_status: Option<DeliveryStatus>,
limit: Option<i64>,
direction: Option<SortDirection>,
content_types: Option<Vec<ContentType>>,
}

impl MsgQueryArgs {
Expand Down Expand Up @@ -273,6 +274,10 @@ impl DbConnection {
query = query.filter(dsl::delivery_status.eq(status));
}

if let Some(content_types) = &args.content_types {
query = query.filter(dsl::content_type.eq_any(content_types));
}

query = match args.direction.as_ref().unwrap_or(&SortDirection::Ascending) {
SortDirection::Ascending => query.order(dsl::sent_at_ns.asc()),
SortDirection::Descending => query.order(dsl::sent_at_ns.desc()),
Expand Down

0 comments on commit 379a28c

Please sign in to comment.