Skip to content

Commit 90d0e05

Browse files
committed
feat(sync): add --chat filter to sync msgs
1 parent c53e794 commit 90d0e05

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/app/sync.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub struct SyncOptions {
4040
pub incremental: bool,
4141
pub messages_per_chat: usize,
4242
pub concurrency: usize,
43+
/// If set, only sync this specific chat
44+
pub chat_filter: Option<i64>,
4345
}
4446

4547
/// Get media type string and file extension from grammers Media enum
@@ -603,9 +605,16 @@ impl App {
603605
let all_chats = self.store.list_chats_with_checkpoint().await?;
604606

605607
// Filter chats to process
608+
let chat_filter = opts.chat_filter;
606609
let chats_to_sync: Vec<_> = all_chats
607610
.into_iter()
608611
.filter(|chat| {
612+
// If chat_filter is set, only include that specific chat
613+
if let Some(filter_id) = chat_filter {
614+
if chat.id != filter_id {
615+
return false;
616+
}
617+
}
609618
if ignore_set.contains(&chat.id) {
610619
return false;
611620
}

src/cmd/daemon.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ pub async fn run(cli: &Cli, args: &DaemonArgs) -> Result<()> {
214214
incremental: true,
215215
messages_per_chat: 50,
216216
concurrency: 4,
217+
chat_filter: None,
217218
};
218219

219220
let result = backfill_app.sync(opts).await;

src/cmd/sync.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ pub enum SyncCommand {
5959
Msgs {
6060
#[command(flatten)]
6161
common: CommonSyncArgs,
62+
63+
/// Sync only this specific chat (by chat ID)
64+
#[arg(long, value_name = "CHAT_ID")]
65+
chat: Option<i64>,
6266
},
6367
}
6468

@@ -97,6 +101,7 @@ fn build_sync_options(common: &CommonSyncArgs) -> crate::app::sync::SyncOptions
97101
incremental: true, // Always incremental
98102
messages_per_chat: common.messages_per_chat,
99103
concurrency: common.concurrency,
104+
chat_filter: None,
100105
}
101106
}
102107

@@ -188,10 +193,11 @@ pub async fn run(cli: &Cli, args: &SyncArgs) -> Result<()> {
188193
let result = app.sync_chats(opts).await?;
189194
print_sync_result(common, &result, "chats-only");
190195
}
191-
Some(SyncCommand::Msgs { common }) => {
196+
Some(SyncCommand::Msgs { common, chat }) => {
192197
// Sync messages only from local chats (uses stored access_hash, no iter_dialogs)
193198
let mut app = App::new(cli).await?;
194-
let opts = build_sync_options(common);
199+
let mut opts = build_sync_options(common);
200+
opts.chat_filter = *chat;
195201
let result = app.sync_msgs(opts).await?;
196202
print_sync_result(common, &result, "msgs-only");
197203
}

0 commit comments

Comments
 (0)