19 package org.turro.mail.message;
21 import java.net.URLDecoder;
22 import java.nio.charset.StandardCharsets;
23 import java.util.regex.Matcher;
24 import java.util.regex.Pattern;
25 import org.turro.action.Actions;
26 import org.turro.elephant.context.ElephantContext;
27 import org.turro.elephant.security.IUser;
28 import org.turro.log.WebLoggers;
29 import org.turro.mail.provider.MailRecipient;
30 import org.turro.plugin.contacts.IContact;
31 import org.turro.string.Strings;
76 if(message.contains(
"{livelink")) {
77 Pattern pat = Pattern.compile(LIVE_LINK_PATTERN);
78 Matcher mat = pat.matcher(message);
79 StringBuffer result =
new StringBuffer();
82 if(mat.groupCount() > 1 && !Strings.isBlank(mat.group(1)) && !Strings.isBlank(mat.group(2))) {
85 mat.appendReplacement(result,
"<a href=\"" + server +
"\">" + mat.group(1) +
"</a>");
87 }
catch (Exception ex) {
91 mat.appendTail(result);
92 return result.toString();
98 if(message.contains(
"{liveref")) {
99 Pattern pat = Pattern.compile(LIVE_REF_PATTERN);
100 Matcher mat = pat.matcher(message);
101 StringBuffer result =
new StringBuffer();
104 if(mat.groupCount() > 0 && !Strings.isBlank(mat.group(1))) {
107 mat.appendReplacement(result, server);
109 }
catch (Exception ex) {
113 mat.appendTail(result);
114 return result.toString();
120 if(message.contains(
"{livelink")) {
121 Pattern pat = Pattern.compile(LIVE_LINK_PATTERN);
122 Matcher mat = pat.matcher(message);
123 StringBuffer result =
new StringBuffer();
126 if(mat.groupCount() > 1 && !Strings.isBlank(mat.group(1)) && !Strings.isBlank(mat.group(2))) {
127 mat.appendReplacement(result,
"<a href='" + mat.group(2) +
"'>" + mat.group(1) +
"</a>");
129 }
catch (Exception ex) {
133 mat.appendTail(result);
134 return result.toString();
140 if(message.contains(
"{liveref")) {
141 Pattern pat = Pattern.compile(LIVE_REF_PATTERN);
142 Matcher mat = pat.matcher(message);
143 StringBuffer result =
new StringBuffer();
146 if(mat.groupCount() > 0 && !Strings.isBlank(mat.group(1))) {
147 mat.appendReplacement(result, mat.group(1));
149 }
catch (Exception ex) {
153 mat.appendTail(result);
154 return result.toString();
159 private static final String LIVE_LINK_PATTERN =
"\\{livelink\\:([^\\:\\}]*)\\:?([^\\:\\}]*)\\}";
160 private static final String LIVE_REF_PATTERN =
"\\{liveref\\:([^\\:\\}]*)\\}";
161 private static final String LINK_PATTERN =
"\\{link\\:([^\\:\\}]*)\\:?([^\\:\\}]*)\\}";
166 return message.replaceAll(
"\\<img ",
"<img style=\"max-width:100%\" ");
178 public static String
processUser(String email, String name, String message) {
184 message = recipient.
parse(message);
193 return text.replaceAll(
"href=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'",
"href=\\'" + serverBase +
"$1$2\\'")
194 .replaceAll(
"src=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'",
"src=\\'" + serverBase +
"$1$2\\'")
195 .replaceAll(
"href=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"",
"href=\\\"" + serverBase +
"$1$2\\\"")
196 .replaceAll(
"src=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"",
"src=\\\"" + serverBase +
"$1$2\\\"");
static String createActionFromElephant(String email, String redir)
static String getServerBase(String scheme)
static String getServerUrl(String scheme)
static WebLoggers severe(Object entity)
WebLoggers exception(Throwable throwable)
static String processLiveRefs(String email, String message)
static String processLinks(IContact contact, String message)
static String cleanLinks(String message)
static String processMacros(IContact contact, String message)
static String processUser(IContact contact, String message)
static String processImgWidth(String message)
static String processLiveLinks(String email, String message)
static String processUser(String email, String name, String message)
static String toAbsolute(String text)
static String cleanLiveLinks(String message)
static String processMacrosForWeb(IContact contact, String message)
static String processLinks(String email, String message)
static String processUser(MailRecipient recipient, String message)
static String cleanLiveRefs(String message)
static MailRecipient of(String value)
String parse(String text)
static final String CONNECTOR_EMAIL