aboutsummaryrefslogtreecommitdiffstats
path: root/src/notmuchworker.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-31 11:44:55 +0100
committerDanilo M. <danix@danix.xyz>2026-10-31 11:44:55 +0100
commit7ef382f7c1ea2dda38f81d007be29ae49612b95f (patch)
tree85e511cd312e932a741c6aeb72db3717db7e35cb /src/notmuchworker.cpp
parent519ee49584bbbf44b2fb132b598d3dd006056116 (diff)
downloadqtmaildir-7ef382f7c1ea2dda38f81d007be29ae49612b95f.tar.gz
qtmaildir-7ef382f7c1ea2dda38f81d007be29ae49612b95f.zip
feat: apply a tag change to every message a query would move
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/notmuchworker.cpp')
-rw-r--r--src/notmuchworker.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/notmuchworker.cpp b/src/notmuchworker.cpp
index 2588f4e..d41b54b 100644
--- a/src/notmuchworker.cpp
+++ b/src/notmuchworker.cpp
@@ -41,6 +41,7 @@
#include "maildirname.h"
#include "mimeparser.h"
#include "nmraii.h"
+#include "searchterm.h"
namespace {
@@ -1082,6 +1083,27 @@ void NotmuchWorker::applyTagsToThreads(const QStringList &threadIds,
applyTags(TagChange{ messageIds, add, remove, description });
}
+void NotmuchWorker::applyTagsToQuery(const QString &query,
+ const QStringList &add,
+ const QStringList &remove,
+ const QString &description)
+{
+ if (!openReadOnly())
+ return;
+
+ QStringList messageIds;
+ if (!collectMessageIds(m_db, SearchTerm::changes(query, add, remove),
+ &messageIds)) {
+ emit errorOccurred(QStringLiteral("Cannot resolve the rule's query"));
+ return;
+ }
+
+ // Empty is not an error: the rule has nothing left to do. applyTags()
+ // returns at once on an empty list, and stays silent, as it must
+ // (CLAUDE.md, item 176).
+ applyTags(TagChange{ messageIds, add, remove, description });
+}
+
void NotmuchWorker::applyTags(const TagChange &change)
{
if (change.messageIds.isEmpty())