IDEMPIERE-5823 - Improve MUserMail constructors to behave equally in every case (#1967)

This commit is contained in:
Diego Ruiz 2023-08-09 06:56:10 +02:00 committed by GitHub
parent e46d57e1ea
commit f1a0f7aac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 25 deletions

View File

@ -34,7 +34,7 @@ public class MUserMail extends X_AD_UserMail
/** /**
* *
*/ */
private static final long serialVersionUID = 925597416692485382L; private static final long serialVersionUID = -6933973466878945692L;
/** /**
* UUID based Constructor * UUID based Constructor
@ -79,15 +79,7 @@ public class MUserMail extends X_AD_UserMail
this (parent.getCtx(), 0, parent.get_TrxName()); this (parent.getCtx(), 0, parent.get_TrxName());
setAD_User_ID(AD_User_ID); setAD_User_ID(AD_User_ID);
setR_MailText_ID(parent.getR_MailText_ID()); setR_MailText_ID(parent.getR_MailText_ID());
setSenderAndRecipient(mail); setMailValues(mail);
//
if (mail.isSentOK())
setMessageID(mail.getMessageID());
else
{
setMessageID(mail.getSentMsg());
setIsDelivered(ISDELIVERED_No);
}
} // MUserMail } // MUserMail
/** /**
@ -101,36 +93,33 @@ public class MUserMail extends X_AD_UserMail
this (po.getCtx(), 0, null); this (po.getCtx(), 0, null);
setClientOrg(po); setClientOrg(po);
setAD_User_ID(AD_User_ID); setAD_User_ID(AD_User_ID);
setSubject(mail.getSubject()); setMailValues(mail);
setMailText(mail.getMessageCRLF());
setSenderAndRecipient(mail);
//
if (mail.isSentOK())
setMessageID(mail.getMessageID());
else
{
setMessageID(mail.getSentMsg());
setIsDelivered(ISDELIVERED_No);
}
} // MUserMail } // MUserMail
public MUserMail (Properties ctx, EMail mail) public MUserMail (Properties ctx, EMail mail)
{ {
this (ctx, 0, null); this (ctx, 0, null);
setAD_User_ID(Env.getAD_User_ID(ctx)); setAD_User_ID(Env.getAD_User_ID(ctx));
setMailValues(mail);
} // MUserMail
/**
* Sets all columns related to the EMail
* Subject - Mail Text - Sender - Recipient - Message ID - IsDelivered
* @param mail
*/
private void setMailValues(EMail mail) {
setSubject(mail.getSubject()); setSubject(mail.getSubject());
setMailText(mail.getMessageCRLF()); setMailText(mail.getMessageCRLF());
setSenderAndRecipient(mail); setSenderAndRecipient(mail);
// //
if (mail.isSentOK()) if (mail.isSentOK())
setMessageID(mail.getMessageID()); setMessageID(mail.getMessageID());
else else {
{
setMessageID(mail.getSentMsg()); setMessageID(mail.getSentMsg());
setIsDelivered(ISDELIVERED_No); setIsDelivered(ISDELIVERED_No);
} }
} // MUserMail }
/** /**
* Is it Delivered * Is it Delivered