From aa452cff1d170490732081a3ecfd3550e230395e Mon Sep 17 00:00:00 2001 From: frectonz Date: Sat, 20 Jun 2026 15:15:48 +0300 Subject: [PATCH] feat: support deleting all messages from inbox --- src/args.rs | 2 ++ src/main.rs | 16 ++++++++++++++++ src/proc_get.rs | 15 +++++++-------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/args.rs b/src/args.rs index a27fbe9..285055a 100644 --- a/src/args.rs +++ b/src/args.rs @@ -73,4 +73,6 @@ pub enum PostCommands { Reboot, /// Delete message from inbox. DeleteSms { msg_id: BoxStr }, + /// Delete all message from inbox. + DeleteAllSms, } diff --git a/src/main.rs b/src/main.rs index df9973e..b33c539 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,22 @@ async fn main() -> EyreResult<()> { .execute::(DeleteSmsParams { msg_id }) .await? } + PostCommands::DeleteAllSms => { + let msg_ids = router + .get::() + .await? + .messages + .into_iter() + .map(|m| m.id) + .collect::>(); + + for msg_id in msg_ids { + println!("Deleting {msg_id}..."); + router + .post_with::(DeleteSmsParams { msg_id }) + .await?; + } + } }, }; router.logout().await?; diff --git a/src/proc_get.rs b/src/proc_get.rs index 77a5071..b0b8f4f 100644 --- a/src/proc_get.rs +++ b/src/proc_get.rs @@ -331,18 +331,17 @@ impl Default for SmsInboxParams { #[derive(Debug, Deserialize)] pub struct SmsInbox { - messages: Vec, + pub messages: Vec, } #[derive(Debug, Deserialize)] pub struct Message { - id: BoxStr, - number: BoxStr, - content: BoxStr, - tag: BoxStr, - date: BoxStr, - #[allow(unused)] - draft_group_id: BoxStr, + pub id: BoxStr, + pub number: BoxStr, + pub content: BoxStr, + pub tag: BoxStr, + pub date: BoxStr, + pub draft_group_id: BoxStr, } enum MessageTagStatus { -- 2.51.2