19 package org.turro.mail.impl;
21 import java.net.URLDecoder;
22 import java.nio.charset.StandardCharsets;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import java.util.regex.Matcher;
26 import java.util.regex.Pattern;
27 import javax.mail.internet.AddressException;
28 import javax.mail.internet.InternetAddress;
29 import org.turro.string.Strings;
30 import org.turro.action.Actions;
31 import org.turro.elephant.context.ElephantContext;
32 import org.turro.elephant.security.IUser;
33 import org.turro.plugin.contacts.IContact;
44 for(InternetAddress ia : InternetAddress.parse(emails,
true)) {
48 }
catch (AddressException ex) {
56 for(InternetAddress ia : InternetAddress.parse(emails,
true)) {
60 }
catch (AddressException ex) {
103 if(message.contains(
"{livelink")) {
104 Pattern pat = Pattern.compile(LIVE_LINK_PATTERN);
105 Matcher mat = pat.matcher(message);
106 StringBuffer result =
new StringBuffer();
109 if(mat.groupCount() > 1 && !Strings.isBlank(mat.group(1)) && !Strings.isBlank(mat.group(2))) {
112 mat.appendReplacement(result,
"<a href=\"" + server +
"\">" + mat.group(1) +
"</a>");
114 }
catch (Exception ex) {
118 mat.appendTail(result);
119 return result.toString();
125 if(message.contains(
"{liveref")) {
126 Pattern pat = Pattern.compile(LIVE_REF_PATTERN);
127 Matcher mat = pat.matcher(message);
128 StringBuffer result =
new StringBuffer();
131 if(mat.groupCount() > 0 && !Strings.isBlank(mat.group(1))) {
134 mat.appendReplacement(result, server);
136 }
catch (Exception ex) {
140 mat.appendTail(result);
141 return result.toString();
147 if(message.contains(
"{livelink")) {
148 Pattern pat = Pattern.compile(LIVE_LINK_PATTERN);
149 Matcher mat = pat.matcher(message);
150 StringBuffer result =
new StringBuffer();
153 if(mat.groupCount() > 1 && !Strings.isBlank(mat.group(1)) && !Strings.isBlank(mat.group(2))) {
154 mat.appendReplacement(result,
"<a href='" + mat.group(2) +
"'>" + mat.group(1) +
"</a>");
156 }
catch (Exception ex) {
160 mat.appendTail(result);
161 return result.toString();
167 if(message.contains(
"{liveref")) {
168 Pattern pat = Pattern.compile(LIVE_REF_PATTERN);
169 Matcher mat = pat.matcher(message);
170 StringBuffer result =
new StringBuffer();
173 if(mat.groupCount() > 0 && !Strings.isBlank(mat.group(1))) {
174 mat.appendReplacement(result, mat.group(1));
176 }
catch (Exception ex) {
180 mat.appendTail(result);
181 return result.toString();
186 private static final String LIVE_LINK_PATTERN =
"\\{livelink\\:([^\\:\\}]*)\\:?([^\\:\\}]*)\\}";
187 private static final String LIVE_REF_PATTERN =
"\\{liveref\\:([^\\:\\}]*)\\}";
188 private static final String LINK_PATTERN =
"\\{link\\:([^\\:\\}]*)\\:?([^\\:\\}]*)\\}";
193 return message.replaceAll(
"\\<img ",
"<img style=\"max-width:100%\" ");
205 public static String
processUser(String email, String name, String message) {
211 message = recipient.
parse(message);
static String createActionFromElephant(String email, String redir)
static String getServerUrl(String scheme)
static String logMsg(String msg)
static String processLinks(String email, String message)
static String cleanLiveLinks(String message)
static String cleanLinks(String message)
static String processImgWidth(String message)
static String processLinks(IContact contact, String message)
static String processUser(IContact contact, String message)
static String cleanLiveRefs(String message)
static String processLiveRefs(String email, String message)
static boolean isValidEmailAddress(String emails)
static String processLiveLinks(String email, String message)
static String processUser(String email, String name, String message)
static String processUser(Recipient recipient, String message)
static String processMacrosForWeb(IContact contact, String message)
static String processMacros(IContact contact, String message)
static boolean silentEmailCheck(String emails)
static Recipient of(IContact contact)
String parse(String text)
static final String CONNECTOR_EMAIL