From b5fdf4a7c5006b90b358851c7be16fecb99703f3 Mon Sep 17 00:00:00 2001 From: Julien Malka Date: Sat, 26 Apr 2025 13:41:48 +0200 Subject: [PATCH] chore: modify mailmover to stop breaking sent folder --- home-manager-modules/mails/mailmover.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) 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