♻️ refactor(rules): execute rules by action
- executes rules by action: `Trash` first, then `Delete` - a label may have a `trash` and `delete` rule applied
This commit is contained in:
committed by
Jeremiah Russell
parent
0d670d3b68
commit
dc41101dcb
@@ -452,12 +452,13 @@ fn get_config() -> Result<(Config, ClientConfig)> {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes automated message retention rules across Gmail labels.
|
/// Executes automated message retention rules across Gmail labels by action.
|
||||||
///
|
///
|
||||||
/// This function orchestrates the rule-based message processing workflow by:
|
/// This function orchestrates the rule-based message processing workflow by:
|
||||||
/// 1. Organizing rules by their target labels
|
/// 1. Executing rules by action: `Trash` first, then `Delete`
|
||||||
/// 2. Processing each label according to its configured rule
|
/// 2. Organizing rules by their target labels
|
||||||
/// 3. Executing or simulating actions based on execution mode
|
/// 3. Processing each label according to its configured rule
|
||||||
|
/// 4. Executing or simulating actions based on execution mode
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
@@ -506,6 +507,7 @@ async fn run_rules(client: &mut GmailClient, rules: Rules, execute: bool) -> Res
|
|||||||
/// * `client` - Mutable Gmail client for API operations
|
/// * `client` - Mutable Gmail client for API operations
|
||||||
/// * `rules` - Loaded rules configuration containing all retention policies
|
/// * `rules` - Loaded rules configuration containing all retention policies
|
||||||
/// * `execute` - Whether to actually perform actions (true) or dry-run (false)
|
/// * `execute` - Whether to actually perform actions (true) or dry-run (false)
|
||||||
|
/// * `action` - The action the rule will execute
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -247,7 +247,13 @@ impl Rules {
|
|||||||
self.rules.values().flat_map(|rule| rule.labels()).collect()
|
self.rules.values().flat_map(|rule| rule.labels()).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find the id of the rule that contains a label
|
/// Find the ids of the rules that contains a label
|
||||||
|
///
|
||||||
|
/// A label may have a `trash` and `delete` rule applied to return a
|
||||||
|
/// maximum of two rules.
|
||||||
|
///
|
||||||
|
/// If a label has more than one `trash` or `delete` rules only the id
|
||||||
|
/// for the last rule will be returned.
|
||||||
fn find_label(&self, label: &str) -> Vec<usize> {
|
fn find_label(&self, label: &str) -> Vec<usize> {
|
||||||
let mut rwl = Vec::new();
|
let mut rwl = Vec::new();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user