From 4d2e4d8b36a95396467d4d270af384755f23090e Mon Sep 17 00:00:00 2001 From: zhenyi <434836402@qq.com> Date: Sat, 30 May 2026 15:07:20 +0800 Subject: [PATCH] refactor: update channel pagination and reconnect --- lib/channel/pagination.rs | 6 +++--- lib/channel/reconnect.rs | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/channel/pagination.rs b/lib/channel/pagination.rs index 811bf1c..09022d0 100644 --- a/lib/channel/pagination.rs +++ b/lib/channel/pagination.rs @@ -65,7 +65,7 @@ impl MessagePagination { db::sqlx::query_as::<_, model::room::RoomMessageModel>( db::sqlx::AssertSqlSafe(format!( "SELECT {RM_COLUMNS} FROM room_message \ - WHERE room = $1 AND seq < $2 AND deleted_at IS NULL \ + WHERE room = $1 AND seq < $2 AND deleted_at IS NULL AND thread IS NULL \ ORDER BY seq DESC LIMIT $3" )), ) @@ -79,7 +79,7 @@ impl MessagePagination { db::sqlx::query_as::<_, model::room::RoomMessageModel>( db::sqlx::AssertSqlSafe(format!( "SELECT {RM_COLUMNS} FROM room_message \ - WHERE room = $1 AND seq > $2 AND deleted_at IS NULL \ + WHERE room = $1 AND seq > $2 AND deleted_at IS NULL AND thread IS NULL \ ORDER BY seq ASC LIMIT $3" )), ) @@ -93,7 +93,7 @@ impl MessagePagination { db::sqlx::query_as::<_, model::room::RoomMessageModel>( db::sqlx::AssertSqlSafe(format!( "SELECT {RM_COLUMNS} FROM room_message \ - WHERE room = $1 AND deleted_at IS NULL \ + WHERE room = $1 AND deleted_at IS NULL AND thread IS NULL \ ORDER BY seq DESC LIMIT $2" )), ) diff --git a/lib/channel/reconnect.rs b/lib/channel/reconnect.rs index 97d394c..0b56e4e 100644 --- a/lib/channel/reconnect.rs +++ b/lib/channel/reconnect.rs @@ -22,6 +22,12 @@ pub struct MissedMessage { pub content: String, pub sender_id: Uuid, pub send_at: chrono::DateTime, + pub thread: Option, + pub parent: Option, + pub content_type: String, + pub pinned: bool, + pub system_type: Option, + pub metadata: serde_json::Value, } #[derive(Clone)] @@ -69,7 +75,7 @@ impl ReconnectManager { let messages = db::sqlx::query_as::<_, RoomMessageModel>( db::sqlx::AssertSqlSafe(format!( "SELECT {RM_COLUMNS} FROM room_message \ - WHERE room = $1 AND seq > $2 AND deleted_at IS NULL \ + WHERE room = $1 AND seq > $2 AND deleted_at IS NULL AND thread IS NULL \ ORDER BY seq ASC \ LIMIT 100" )), @@ -88,6 +94,12 @@ impl ReconnectManager { content: m.content, sender_id: m.author, send_at: m.created_at, + thread: m.thread, + parent: m.parent, + content_type: m.content_type, + pinned: m.pinned, + system_type: m.system_type, + metadata: m.metadata, }) .collect();