if (isCancelled(request)){
return mapping.findForward(BaseConstants.FWD_CANCEL);
}
PrivateMessageForm pmForm = (PrivateMessageForm) form;
PrivateMessageVO pmVO = new PrivateMessageVO();
PrivateMessageVO pmVOCopy = new PrivateMessageVO();
BeanUtils.copyProperties(pmVO, pmForm);
BeanUtils.copyProperties(pmVOCopy, pmForm);
String toMemberEmail = memService.getMemberEmailByMemberId(pmVO.getMessageToUserId());
SystemConfigVO sysConfigVO = sysConfigSerivce.getSystemConfig();
if (pmVO.getType().equals("contact")) {
if (!memService.isAccountActivatedByMemberId(pmVO.getMessageToUserId())) {
ActionMessages errors = new ActionMessages();
errors.add(BaseConstants.FATAL_KEY, new ActionMessage("message.mail.unactivatedmember"));
saveMessages(request, errors);
return mapping.getInputForward();
}
else {
int quota = pmService.getQuotaRatioByMemberId(pmVO.getMessageToUserId());
if (quota < SystemConfigConstants.MAIL_QUOTA ){
pmVO.setMessageId(null);
pmVOCopy.setMessageId(null);
pmService.contactMail(pmVO, getLastModifiedBy(request), getCurrentIPAddress(request));
SendMailUtil.memberNewMessageNotification(pmVO, sysConfigVO, toMemberEmail);
//copy to sent
if (pmForm.getCopyMe().equalsIgnoreCase(BaseConstants.BOOLEAN_YES)){
pmService.copyMeOnContactMail(pmVOCopy, getLastModifiedBy(request),getCurrentIPAddress(request));
}
}
else{
ActionMessages errors = new ActionMessages();
errors.add(BaseConstants.WARN_KEY, new ActionMessage("error.mailboxfull"));
saveMessages(request, errors);
}
}
}
else if (pmVO.getType().equals("reply")) {
pmVO.setMessageFromUserId(token.getMemberId());
int quota = pmService.getQuotaRatioByMemberId(pmVO.getMessageToUserId());
if (quota < SystemConfigConstants.MAIL_QUOTA ){
pmVO.setMessageId(null); // setting to null becasue its a considered a new
pmService.replyMail(pmVO, getLastModifiedBy(request),getCurrentIPAddress(request));
SendMailUtil.memberNewMessageNotification(pmVO, sysConfigVO, toMemberEmail);
//copy to sent
if (pmForm.getCopyMe().equalsIgnoreCase(BaseConstants.BOOLEAN_YES)){
pmService.copyMeOnReplyMail(pmVOCopy, getLastModifiedBy(request),getCurrentIPAddress(request));
}
}
else{
// TODO: Maybe save the message as a draft to be sent later