Skip to content

Commit

Permalink
fix after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mchenani committed Dec 20, 2024
1 parent a8c2097 commit 0f88bc4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 19 deletions.
1 change: 1 addition & 0 deletions xmtp_mls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ diesel = { workspace = true, features = [
"r2d2",
"returning_clauses_for_sqlite_3_35",
"sqlite",
"32-column-tables"
] }
dyn-clone.workspace = true
libsqlite3-sys = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ WITH ranked_messages AS (
gm.sender_installation_id,
gm.sender_inbox_id,
gm.delivery_status,
gm.content_type,
gm.version_major,
gm.version_minor,
gm.authority_id,
ROW_NUMBER() OVER (PARTITION BY gm.group_id ORDER BY gm.sent_at_ns DESC) AS row_num
FROM
group_messages gm
Expand All @@ -31,7 +35,11 @@ SELECT
rm.message_kind,
rm.sender_installation_id,
rm.sender_inbox_id,
rm.delivery_status
rm.delivery_status,
rm.content_type,
rm.version_major,
rm.version_minor,
rm.authority_id
FROM
groups g
LEFT JOIN ranked_messages rm
Expand Down
4 changes: 4 additions & 0 deletions xmtp_mls/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,10 @@ where
sender_inbox_id: conversation_item.sender_inbox_id?,
kind: conversation_item.kind?,
delivery_status: conversation_item.delivery_status?,
content_type: conversation_item.content_type?,
version_major: conversation_item.version_major?,
version_minor: conversation_item.version_minor?,
authority_id: conversation_item.authority_id?,
})
});

Expand Down
16 changes: 14 additions & 2 deletions xmtp_mls/src/storage/encrypted_store/conversation_list.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::storage::group::{ConversationType, GroupMembershipState};
use crate::storage::group_message::{DeliveryStatus, GroupMessageKind};
use crate::storage::group_message::{ContentType, DeliveryStatus, GroupMessageKind};
use crate::storage::schema::conversation_list::dsl::conversation_list;
use crate::storage::{DbConnection, StorageError};
use diesel::{QueryDsl, Queryable, RunQueryDsl, Table};
Expand Down Expand Up @@ -42,6 +42,14 @@ pub struct ConversationListItem {
pub sender_inbox_id: Option<String>,
/// We optimistically store messages before sending.
pub delivery_status: Option<DeliveryStatus>,
/// The Content Type of the message
pub content_type: Option<ContentType>,
/// The content type version major
pub version_major: Option<i32>,
/// The content type version minor
pub version_minor: Option<i32>,
/// The ID of the authority defining the content type
pub authority_id: Option<String>,
}

impl DbConnection {
Expand Down Expand Up @@ -73,7 +81,8 @@ pub(crate) mod tests {
crate::storage::encrypted_store::group_message::tests::generate_message(
None,
Some(&group.id),
Some(i * 1000), // Increment timestamp for each message
Some(i * 1000),
None,
);
message.store(conn).unwrap();
}
Expand Down Expand Up @@ -109,6 +118,7 @@ pub(crate) mod tests {
None,
Some(&group_b.id),
Some(3000), // Last message timestamp
None,
);
message.store(conn).unwrap();

Expand Down Expand Up @@ -144,6 +154,7 @@ pub(crate) mod tests {
None,
Some(&group.id),
Some(1000),
None,
);
first_message.store(conn).unwrap();

Expand All @@ -162,6 +173,7 @@ pub(crate) mod tests {
None,
Some(&group.id),
Some(2000),
None,
);
second_message.store(conn).unwrap();

Expand Down
36 changes: 20 additions & 16 deletions xmtp_mls/src/storage/encrypted_store/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,26 @@ diesel::table! {

diesel::table! {
conversation_list (id) {
id -> Binary,
created_at_ns -> BigInt,
membership_state -> Integer,
installations_last_checked -> BigInt,
added_by_inbox_id -> Text,
welcome_id -> Nullable<BigInt>,
dm_inbox_id -> Nullable<Text>,
rotated_at_ns -> BigInt,
conversation_type -> Integer,
message_id -> Nullable<Binary>,
decrypted_message_bytes -> Nullable<Binary>,
sent_at_ns -> Nullable<BigInt>,
message_kind -> Nullable<Integer>,
sender_installation_id -> Nullable<Binary>,
sender_inbox_id -> Nullable<Text>,
delivery_status -> Nullable<Integer>,
id -> Binary,
created_at_ns -> BigInt,
membership_state -> Integer,
installations_last_checked -> BigInt,
added_by_inbox_id -> Text,
welcome_id -> Nullable<BigInt>,
dm_inbox_id -> Nullable<Text>,
rotated_at_ns -> BigInt,
conversation_type -> Integer,
message_id -> Nullable<Binary>,
decrypted_message_bytes -> Nullable<Binary>,
sent_at_ns -> Nullable<BigInt>,
message_kind -> Nullable<Integer>,
sender_installation_id -> Nullable<Binary>,
sender_inbox_id -> Nullable<Text>,
delivery_status -> Nullable<Integer>,
content_type -> Nullable<Integer>,
version_major -> Nullable<Integer>,
version_minor -> Nullable<Integer>,
authority_id -> Nullable<Text>
}
}

Expand Down

0 comments on commit 0f88bc4

Please sign in to comment.