]> git.basschouten.com Git - openhab-addons.git/commitdiff
[mail] Support chaining transformations without an intersection symbol (#17314)
authorjimtng <2554958+jimtng@users.noreply.github.com>
Fri, 23 Aug 2024 16:48:52 +0000 (02:48 +1000)
committerGitHub <noreply@github.com>
Fri, 23 Aug 2024 16:48:52 +0000 (18:48 +0200)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
bundles/org.openhab.binding.mail/README.md
bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/config/POP3IMAPContentChannelConfig.java
bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties
bundles/org.openhab.binding.mail/src/main/resources/OH-INF/thing/thing-types.xml

index 06cfe9dede96332a53fd6d8c749f6ae41292e04d..2d5e58fc69cc6d9433c465ab96a17429a823f50b 100644 (file)
@@ -69,7 +69,10 @@ Filters use regular expressions (e.g. `.*DHL.*` as `sender` would match all From
 If a parameter is left empty, no filter is applied.
 
 The `transformation` is applied before setting the channel status.
-Transformations can be chained by separating them with the mathematical intersection character "∩", e.g. `REGEX:.*Shipment-Status: ([a-z]+).*∩MAP:status.map` would first extract a character string with a regular expression and then apply the given MAP transformation on the result.
+Transformations are defined using this syntax: `TYPE(FUNCTION)`, e.g.: `JSONPATH($.path)`.
+The syntax: `TYPE:FUNCTION` is still supported, e.g.: `JSONPATH:$.path`.
+Transformations can be chained in the UI by listing each transformation on a separate line, or by separating them with the mathematical intersection character "∩".
+For example, `REGEX(.*Shipment-Status: ([a-z]+).*) ∩ MAP(status.map)` would first extract a character string with a regular expression and then apply the given MAP transformation on the result.
 Please note that the values will be discarded if one transformation fails (e.g. REGEX did not match).
 This means that you can also use it to filter certain emails e.g. `REGEX:(.*Sendungsbenachrichtigung.*)` would only match for mails containing the string "Sendungsbenachrichtigung" but output the whole message.
 
index 058585e48eb61bd1575fb8a7343a71fb6b91837a..b9f6007aaf0d918133554ada75bdcd34a148a83f 100644 (file)
@@ -12,6 +12,8 @@
  */
 package org.openhab.binding.mail.internal.config;
 
+import java.util.List;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
@@ -25,7 +27,7 @@ public class POP3IMAPContentChannelConfig {
     public @Nullable String folder;
     public String subject = "";
     public String sender = "";
-    public @Nullable String transformation;
+    public @Nullable List<String> transformation;
 
     public boolean markAsRead = false;
 }
index 2a8b1251cf6a02791b53d14f773c936868a631ad..1fc84fc970e9b11e40d58c4ba2e2e37e708d2005 100644 (file)
@@ -37,7 +37,7 @@ channel-type.config.mail.content.sender.description = A (regular expression) fil
 channel-type.config.mail.content.subject.label = Subject Filter
 channel-type.config.mail.content.subject.description = A (regular expression) filter for the mail subject.
 channel-type.config.mail.content.transformation.label = Transformation
-channel-type.config.mail.content.transformation.description = Transformation pattern used when processing messages. Multiple transformation can be chained using "∩".
+channel-type.config.mail.content.transformation.description = Transformation pattern used when processing messages. Multiple transformations can be chained by listing each transformation on a separate line, or by concatenating them with "∩".
 channel-type.config.mail.mailcount.folder.label = Folder Name
 channel-type.config.mail.mailcount.type.label = Counter Type
 channel-type.config.mail.mailcount.type.option.UNREAD = Unread
index dd68b3519aff3cb227932c6218166f09039bc669..d4b42fc652ccb30a7bca318ea381a6d47edf1dd5 100644 (file)
                                <label>Sender Filter</label>
                                <description>A (regular expression) filter for the mail sender address.</description>
                        </parameter>
-                       <parameter name="transformation" type="text">
+                       <parameter name="transformation" type="text" multiple="true">
                                <label>Transformation</label>
-                               <description>Transformation pattern used when processing messages. Multiple transformation can be chained using "∩".</description>
+                               <description>Transformation pattern used when processing messages. Multiple transformations can be chained by
+                                       listing
+                                       each transformation on a separate line, or by concatenating them with "∩".</description>
                        </parameter>
                        <parameter name="markAsRead" type="boolean">
                                <label>Mark As Read</label>