From 83a5c45cb579fa71d278482c75a24d87dfc76054 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Wed, 29 Oct 2025 13:50:04 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(gmail):=20use=20GMAIL=5FDELE?= =?UTF-8?q?TE=5FSCOPE=20for=20batch=20delete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - use GMAIL_DELETE_SCOPE instead of GMAIL_MODIFY_SCOPE for batch delete operation - GMAIL_DELETE_SCOPE is required for batch delete to work --- src/rule_processor.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rule_processor.rs b/src/rule_processor.rs index 2a2bf78..62f5d02 100644 --- a/src/rule_processor.rs +++ b/src/rule_processor.rs @@ -64,6 +64,13 @@ const TRASH_LABEL: &str = "TRASH"; /// modification operations. Preferred over broader scopes for security. const GMAIL_MODIFY_SCOPE: &str = "https://www.googleapis.com/auth/gmail.modify"; +/// Gmail API scope for deleting messages. +/// +/// This scope allows all operations and is required to authorise the batch +/// delete operation. It is only used for batch delete. For all other +/// operations `GMAIL_MODIFY_SCOPE` is preferred. +const GMAIL_DELETE_SCOPE: &str = "https://mail.google.com/"; + /// Internal trait defining the minimal operations needed for rule processing. /// /// This trait is used internally to enable unit testing of orchestration logic @@ -424,7 +431,7 @@ impl RuleProcessor for GmailClient { .hub() .users() .messages_batch_delete(batch_request, "me") - .add_scope(GMAIL_MODIFY_SCOPE) + .add_scope(GMAIL_DELETE_SCOPE) .doit() .await .map_err(Box::new);