diff --git a/home-manager-modules/mails/mailmover.lua b/home-manager-modules/mails/mailmover.lua index 30196ad..0f0c046 100644 --- a/home-manager-modules/mails/mailmover.lua +++ b/home-manager-modules/mails/mailmover.lua @@ -32,6 +32,11 @@ local function is_parent_path(parent, child) return child:match("^" .. parent .. "/") ~= nil end +--- Check if a folder contains "Archive" in its name +local function contains_archive(folder) + return string.find(folder, "Archive") ~= nil +end + --- Generate rules based on folder structure local function generate_rules(maildir_path) local folders = get_maildir_folders(maildir_path) @@ -98,6 +103,11 @@ local function generate_rules(maildir_path) end end + -- Add "not tag:sent" for any folder containing "Archive" + if contains_archive(folder) then + table.insert(exclusion_parts, "not tag:sent") + end + -- Build the complete query local query = table.concat(query_parts, " and ") if #exclusion_parts > 0 then