diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index 7b84f1bdc..a03de17c6 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -1326,10 +1326,10 @@ impl FfiConversation { .find_messages(&MsgQueryArgs { sent_before_ns: opts.sent_before_ns, sent_after_ns: opts.sent_after_ns, - kind: kind, - delivery_status: delivery_status, limit: opts.limit, - direction: direction, + kind, + delivery_status, + direction, })? .into_iter() .map(|msg| msg.into()) diff --git a/xmtp_mls/src/storage/encrypted_store/group.rs b/xmtp_mls/src/storage/encrypted_store/group.rs index 9c14c6be9..db624686a 100644 --- a/xmtp_mls/src/storage/encrypted_store/group.rs +++ b/xmtp_mls/src/storage/encrypted_store/group.rs @@ -223,8 +223,16 @@ impl DbConnection { } = args.as_ref(); let mut query = groups_dsl::groups - // Filter out sync groups from the main query .filter(groups_dsl::conversation_type.ne(ConversationType::Sync)) + // Group by dm_id and grab the latest group (conversation stitching) + .filter(sql::( + "id IN ( + SELECT id + FROM groups + GROUP BY CASE WHEN dm_id IS NULL THEN id ELSE dm_id END + ORDER BY last_message_ns DESC + )", + )) .order(groups_dsl::created_at_ns.asc()) .into_boxed();