Commit f777f508dbd8
Changed files (1)
home
common
services
home/common/services/imapfilter-config.lua
@@ -106,22 +106,27 @@ function apply_rules(messages, rules, action, folder_name)
end
-- Perform the action
- if action == 'delete' then
- results:delete_messages()
- elseif action == 'archive' then
- archive_by_year(results)
- elseif action == 'move' then
- if not folder_name then
- print("Error: folder_name required for 'move' action")
- return results
+ if #results > 0 then
+ print(string.format(" → Matched %d message(s)", #results))
+ if action == 'delete' then
+ results:delete_messages()
+ elseif action == 'archive' then
+ archive_by_year(results)
+ elseif action == 'move' then
+ if not folder_name then
+ print("Error: folder_name required for 'move' action")
+ return results
+ end
+ -- Ensure folder exists
+ account:create_mailbox(folder_name)
+ results:move_messages(account[folder_name])
+ else
+ print("Unknown action: " .. action)
end
- -- Ensure folder exists
- account:create_mailbox(folder_name)
- results:move_messages(account[folder_name])
else
- print("Unknown action: " .. action)
+ print(" → No matches")
end
-
+
return results
end
@@ -175,6 +180,7 @@ local archive_rules = load_rules_from_file(rules_dir .. "/archive.txt")
-- Get all messages in INBOX
messages = account['INBOX']:select_all()
+print(string.format("Processing %d messages from INBOX", #messages))
-- Apply filters
print("Applying delete rules...")
@@ -192,7 +198,12 @@ apply_rules(messages, archive_rules, 'archive')
-- GitHub notifications (existing rule)
print("Moving GitHub notifications...")
github = messages:contain_from('notifications@github.com')
-account:create_mailbox('_trackers/github')
-github:move_messages(account['_trackers/github'])
+if #github > 0 then
+ print(string.format(" → Matched %d message(s)", #github))
+ account:create_mailbox('_trackers/github')
+ github:move_messages(account['_trackers/github'])
+else
+ print(" → No matches")
+end
print("Filtering complete!")