From ebc15f66aa04992406559d419bfdc0fab446616b Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 6 Mar 2025 16:09:14 +0100 Subject: [PATCH] Added user/domain place holders for move rule action --- FAQ.md | 7 +++++++ app/src/main/java/eu/faircode/email/EntityRule.java | 10 ++++++++++ index.html | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/FAQ.md b/FAQ.md index 48a6d3813a..a6c56408f1 100644 --- a/FAQ.md +++ b/FAQ.md @@ -3012,10 +3012,17 @@ $day$ (since version 1.2030) $week$ $month$ $year$ +$user$ (since version 1.2265) +$extra$ (since version 1.2265) $domain$ $group$ (since version 1.2030) ``` +$user$ is the domain name of the 'from' email address, +and $domain$ is the domain name of the 'from' email address: *user@domain*. + +$extra$ is the part after the plus sign if the username: *user+extra$example.org*. + $group$ will be replaced with the contact group name of the sender, provided that the related contact is assigned to one contact group only. Note that the Android contact provider isn't very fast, so using this placeholder can slow down fetching messages. diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java index 40f32c62d1..b3658a2a29 100644 --- a/app/src/main/java/eu/faircode/email/EntityRule.java +++ b/app/src/main/java/eu/faircode/email/EntityRule.java @@ -863,13 +863,23 @@ public class EntityRule { create = create.replace("$week$", week); create = create.replace("$day$", day); + String user = null; + String extra = null; String domain = null; if (message.from != null && message.from.length > 0 && message.from[0] instanceof InternetAddress) { InternetAddress from = (InternetAddress) message.from[0]; + user = UriHelper.getEmailUser(from.getAddress()); domain = UriHelper.getEmailDomain(from.getAddress()); + if (user != null) { + int plus = user.indexOf('+'); + if (plus > 0) + extra = user.substring(plus + 1); + } } + create = create.replace("$user$", user == null ? "" : user); + create = create.replace("$extra$", extra == null ? "" : extra); create = create.replace("$domain$", domain == null ? "" : domain); if (create.contains("$group$")) { diff --git a/index.html b/index.html index e468c689e4..99d307bb1a 100644 --- a/index.html +++ b/index.html @@ -1658,8 +1658,12 @@ X-Google-Original-From: Somebody <somebody+extra@example.org> $week$ $month$ $year$ +$user$ (since version 1.2265) +$extra$ (since version 1.2265) $domain$ $group$ (since version 1.2030) +

user is the domain name of the ‘from’ email address, and domain is the domain name of the ‘from’ email address: user@domain.

+

extra is the part after the plus sign if the username: user+extra$example.org.

group will be replaced with the contact group name of the sender, provided that the related contact is assigned to one contact group only. Note that the Android contact provider isn’t very fast, so using this placeholder can slow down fetching messages.


Since version 1.2132 it is possible to use the following placeholders in keywords: