From c08505817cf835e6dee0def87fcf938c7f3517e8 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 15 Sep 2026 11:08:59 +0200 Subject: [PATCH] Expresion condition: added via --- CHANGELOG.md | 2 +- FAQ.md | 1 + app/src/main/assets/CHANGELOG.md | 2 +- .../java/eu/faircode/email/ExpressionHelper.java | 13 ++++++++++++- index.html | 1 + metadata/en-US/changelogs/2333.txt | 2 +- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e684cce4ee..81dcc305bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,7 @@ For support you can use [the contact form](https://contact.faircode.eu/?product= * Fixed all reported issues * Added drag and drop to address bubbles -* Added *submitter*, *cc*, *bcc* and *replyto* to [expression conditions](https://m66b.github.io/FairEmail/#expression_conditions) +* Added *via*, *submitter*, *cc*, *bcc* and *replyto* to [expression conditions](https://m66b.github.io/FairEmail/#expression_conditions) ### 1.2333 2026-09-01 diff --git a/FAQ.md b/FAQ.md index b9bef222a8..884cc5f2e0 100644 --- a/FAQ.md +++ b/FAQ.md @@ -3021,6 +3021,7 @@ Commonly used are && (=and) and || (=or). The following extra variables are available: * *received* (long, unix epoch in milliseconds; since version 1.2179) +* *via* (array of strings, [matched identity](#faq34); since version 1.2234) * *submitter* (array of strings, sent on behalf of; since version 1.2234) * *from* (array of strings) * *to* (array of strings) diff --git a/app/src/main/assets/CHANGELOG.md b/app/src/main/assets/CHANGELOG.md index e684cce4ee..81dcc305bb 100644 --- a/app/src/main/assets/CHANGELOG.md +++ b/app/src/main/assets/CHANGELOG.md @@ -32,7 +32,7 @@ For support you can use [the contact form](https://contact.faircode.eu/?product= * Fixed all reported issues * Added drag and drop to address bubbles -* Added *submitter*, *cc*, *bcc* and *replyto* to [expression conditions](https://m66b.github.io/FairEmail/#expression_conditions) +* Added *via*, *submitter*, *cc*, *bcc* and *replyto* to [expression conditions](https://m66b.github.io/FairEmail/#expression_conditions) ### 1.2333 2026-09-01 diff --git a/app/src/main/java/eu/faircode/email/ExpressionHelper.java b/app/src/main/java/eu/faircode/email/ExpressionHelper.java index 5467f266ea..eea0329575 100644 --- a/app/src/main/java/eu/faircode/email/ExpressionHelper.java +++ b/app/src/main/java/eu/faircode/email/ExpressionHelper.java @@ -63,7 +63,7 @@ import javax.mail.internet.InternetHeaders; public class ExpressionHelper { private static final List EXPR_VARIABLES = Collections.unmodifiableList(Arrays.asList( - "received", "return_path", "submitter", "from", "to", "cc", "bcc", "subject", "replyto", "text", "hasAttachments" + "received", "return_path", "via", "submitter", "from", "to", "cc", "bcc", "subject", "replyto", "text", "hasAttachments" )); static void check(Expression expression) throws ParseException { @@ -90,6 +90,16 @@ public class ExpressionHelper { for (Address a : message.return_path) return_path.add(MessageHelper.formatAddresses(new Address[]{a})); + List via = new ArrayList<>(); + if (message != null && message.identity != null) try { + DB db = DB.getInstance(context); + EntityIdentity identity = db.identity().getIdentity(message.id); + if (identity != null) + via.add(MessageHelper.formatAddresses(new Address[]{new InternetAddress(identity.email, identity.name)})); + } catch (Throwable ex) { + Log.e(ex); + } + List submitter = new ArrayList<>(); if (message != null && message.submitter != null) for (Address a : message.submitter) @@ -174,6 +184,7 @@ public class ExpressionHelper { Expression expression = new Expression(eval, configuration) .with("received", message == null ? null : message.received) .with("return_path", return_path) + .with("via", via) .with("submitter", submitter) .with("from", from) .with("to", to) diff --git a/index.html b/index.html index 8b62b1ba8a..56c31572f2 100644 --- a/index.html +++ b/index.html @@ -1647,6 +1647,7 @@ X-Google-Original-From: Somebody <somebody+extra@example.org>

The following extra variables are available:

  • received (long, unix epoch in milliseconds; since version 1.2179)
  • +
  • via (array of strings, matched identity; since version 1.2234)
  • submitter (array of strings, sent on behalf of; since version 1.2234)
  • from (array of strings)
  • to (array of strings)
  • diff --git a/metadata/en-US/changelogs/2333.txt b/metadata/en-US/changelogs/2333.txt index 39f4a264da..0f09c5af75 100644 --- a/metadata/en-US/changelogs/2333.txt +++ b/metadata/en-US/changelogs/2333.txt @@ -32,7 +32,7 @@ Next version (Work in progress) * Fixed all reported issues * Added drag and drop to address bubbles -* Added *submitter*, *cc*, *bcc* and *replyto* to expression conditions +* Added *via*, *submitter*, *cc*, *bcc* and *replyto* to expression conditions 1.2333 2026-09-01