IDEMPIERE-4461 : Feedback email recipient(s) : add flexibility (#261)

* IDEMPIERE-4461 : Feedback email recipient(s) : add flexibility

Search recipients in SysConfig and if not found, fallback on System.SupportEMail

* IDEMPIERE-4461 : Feedback email recipient(s) : add flexibility

fixes suggested by @hengsin

Co-authored-by: hengsin <152246+hengsin@users.noreply.github.com>
This commit is contained in:
Nicolas Micoud 2020-10-16 17:22:19 +02:00 committed by GitHub
parent a21fe225e1
commit 4856ca67fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -43,7 +43,7 @@ public class MSysConfig extends X_AD_SysConfig
/**
*
*/
private static final long serialVersionUID = 4339975517612838655L;
private static final long serialVersionUID = -7393845332390162370L;
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
@ -96,6 +96,8 @@ public class MSysConfig extends X_AD_SysConfig
public static final String EMAIL_NOTIFY_2PACK = "EMAIL_NOTIFY_2PACK";
public static final String EMAIL_TEST_MAILTEXT_ID = "EMAIL_TEST_MAILTEXT_ID";
public static final String ENABLE_PAYMENTBOX_BUTTON = "ENABLE_PAYMENTBOX_BUTTON";
public static final String FEEDBACK_EMAIL_CC = "FEEDBACK_EMAIL_CC";
public static final String FEEDBACK_EMAIL_TO = "FEEDBACK_EMAIL_TO";
public static final String GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS = "GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS";
public static final String HTML_REPORT_THEME = "HTML_REPORT_THEME";
public static final String IBAN_VALIDATION = "IBAN_VALIDATION";

View File

@ -22,9 +22,11 @@ import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.FeedbackManager;
import org.adempiere.webui.window.WEMailDialog;
import org.compiere.model.MSysConfig;
import org.compiere.model.MSystem;
import org.compiere.model.MUser;
import org.compiere.util.ByteArrayDataSource;
import org.compiere.util.EMail;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
@ -113,10 +115,22 @@ public class DefaultFeedbackService implements IFeedbackService {
dialog.setAttribute(Window.MODE_KEY, Mode.OVERLAPPED);
MSystem system = MSystem.get(Env.getCtx());
if (!Util.isEmpty(system.getSupportEMail()))
for (String s : getFeedbackRecipient(MSysConfig.FEEDBACK_EMAIL_TO).split(",")) {
if (!Util.isEmpty(s.trim()) && EMail.validate(s.trim()))
dialog.addTo(s.trim(), false);
}
if (Util.isEmpty(dialog.getTo()) && !Util.isEmpty(system.getSupportEMail()))
{
dialog.addTo(system.getSupportEMail(), true);
}
for (String s : getFeedbackRecipient(MSysConfig.FEEDBACK_EMAIL_CC).split(",")) {
if (!Util.isEmpty(s.trim()) && EMail.validate(s.trim()))
dialog.addCC(s.trim(), false);
}
AEnv.showWindow(dialog);
if (imageBytes != null && imageBytes.length > 0) {
ByteArrayDataSource screenShot = new ByteArrayDataSource(imageBytes, "image/png");
@ -125,6 +139,11 @@ public class DefaultFeedbackService implements IFeedbackService {
}
dialog.focus();
}
protected String getFeedbackRecipient(String scValue) {
String retValue = MSysConfig.getValue(scValue, Env.getAD_Client_ID(Env.getCtx()), Env.getAD_Org_ID(Env.getCtx()));
return Util.isEmpty(retValue) ? "" : retValue;
}
}
protected static class CreateNewRequestAction implements EventListener<Event>{