diff --git a/api/libs/database/src/models.rs b/api/libs/database/src/models.rs index 6a2920f80..92ca78537 100644 --- a/api/libs/database/src/models.rs +++ b/api/libs/database/src/models.rs @@ -114,6 +114,7 @@ pub struct Chat { pub public_expiry_date: Option>, pub most_recent_file_id: Option, pub most_recent_file_type: Option, + pub most_recent_version_number: Option, } #[derive(Queryable, Insertable, Associations, Debug)] diff --git a/api/libs/database/src/schema.rs b/api/libs/database/src/schema.rs index 81669d59b..a07133a7f 100644 --- a/api/libs/database/src/schema.rs +++ b/api/libs/database/src/schema.rs @@ -98,6 +98,7 @@ diesel::table! { most_recent_file_id -> Nullable, #[max_length = 255] most_recent_file_type -> Nullable, + most_recent_version_number -> Nullable, } } diff --git a/api/libs/handlers/src/chats/duplicate_chat_handler.rs b/api/libs/handlers/src/chats/duplicate_chat_handler.rs index cbffb1e7e..2aef8fa2c 100644 --- a/api/libs/handlers/src/chats/duplicate_chat_handler.rs +++ b/api/libs/handlers/src/chats/duplicate_chat_handler.rs @@ -82,6 +82,7 @@ pub async fn duplicate_chat_handler( public_expiry_date: None, most_recent_file_id: source_chat.most_recent_file_id, most_recent_file_type: source_chat.most_recent_file_type.clone(), + most_recent_version_number: source_chat.most_recent_version_number, }; // Insert the new chat record diff --git a/api/libs/handlers/src/chats/list_chats_handler.rs b/api/libs/handlers/src/chats/list_chats_handler.rs index 76aa485c6..201ad4479 100644 --- a/api/libs/handlers/src/chats/list_chats_handler.rs +++ b/api/libs/handlers/src/chats/list_chats_handler.rs @@ -33,6 +33,7 @@ pub struct ChatListItem { pub last_edited: String, pub latest_file_id: Option, pub latest_file_type: Option, + pub latest_version_number: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -58,6 +59,7 @@ struct ChatWithUser { pub created_by: Uuid, pub most_recent_file_id: Option, pub most_recent_file_type: Option, + pub most_recent_version_number: Option, // User fields pub user_name: Option, pub user_attributes: Value, @@ -128,6 +130,7 @@ pub async fn list_chats_handler( chats::created_by, chats::most_recent_file_id, chats::most_recent_file_type, + chats::most_recent_version_number, users::name.nullable(), users::attributes, )) @@ -158,6 +161,7 @@ pub async fn list_chats_handler( last_edited: chat.updated_at.to_rfc3339(), latest_file_id: chat.most_recent_file_id.map(|id| id.to_string()), latest_file_type: chat.most_recent_file_type, + latest_version_number: chat.most_recent_version_number, } }) .collect(); diff --git a/api/libs/handlers/src/chats/post_chat_handler.rs b/api/libs/handlers/src/chats/post_chat_handler.rs index 6274807ad..32802050e 100644 --- a/api/libs/handlers/src/chats/post_chat_handler.rs +++ b/api/libs/handlers/src/chats/post_chat_handler.rs @@ -2101,6 +2101,7 @@ async fn initialize_chat( public_expiry_date: None, most_recent_file_id: None, most_recent_file_type: None, + most_recent_version_number: None, }; // Create initial message diff --git a/api/migrations/2025-04-08-213658_add_most_recent_version_number_to_chats/down.sql b/api/migrations/2025-04-08-213658_add_most_recent_version_number_to_chats/down.sql new file mode 100644 index 000000000..3ee1fc59e --- /dev/null +++ b/api/migrations/2025-04-08-213658_add_most_recent_version_number_to_chats/down.sql @@ -0,0 +1,4 @@ +-- This file should undo anything in `up.sql` + +ALTER TABLE chats +DROP COLUMN most_recent_version_number; diff --git a/api/migrations/2025-04-08-213658_add_most_recent_version_number_to_chats/up.sql b/api/migrations/2025-04-08-213658_add_most_recent_version_number_to_chats/up.sql new file mode 100644 index 000000000..e5de38845 --- /dev/null +++ b/api/migrations/2025-04-08-213658_add_most_recent_version_number_to_chats/up.sql @@ -0,0 +1,4 @@ +-- Your SQL goes here + +ALTER TABLE chats +ADD COLUMN most_recent_version_number INTEGER; diff --git a/api/server/src/routes/rest/routes/chats/duplicate_chat.rs b/api/server/src/routes/rest/routes/chats/duplicate_chat.rs index d3da978af..6b6466622 100644 --- a/api/server/src/routes/rest/routes/chats/duplicate_chat.rs +++ b/api/server/src/routes/rest/routes/chats/duplicate_chat.rs @@ -136,6 +136,7 @@ mod tests { public_expiry_date: None, most_recent_file_id: None, most_recent_file_type: None, + most_recent_version_number: None, }; let mut conn = get_pg_pool().get().await.unwrap();