updated to append the original message on mail reply

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-mail-servlet@120085 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-10-29 10:44:24 +00:00
parent 1939ab6cb0
commit f773e72185
1 changed files with 17 additions and 1 deletions

View File

@ -241,6 +241,8 @@ public class PeriodicTask implements Runnable {
recipientIds = theMessage.getAddresses();
//add the sender and remove the person who is replying from the recipients
String sender = theMessage.getSender().getPortalLogin();
String originalText = theMessage.getBody();
Date originalSentTime = theMessage.getSendTime().getTime();
recipientIds.add(sender);
recipientIds.remove(fakeSession.getUsername());
@ -248,7 +250,9 @@ public class PeriodicTask implements Runnable {
for (String rec : recipientIds) {
_log.debug(rec);
}
_log.debug("Constructing repy message");
messageText += getReplyHeaderMessage(sender, originalSentTime, originalText);
_log.debug("Trying to send message with subject: " + subject, " to: " + recipientIds.toString());
newMessageId = messageManager.sendMessageToPortalLogins(subject, messageText, new ArrayList<String>(), recipientIds);
@ -269,6 +273,18 @@ public class PeriodicTask implements Runnable {
}
}
private String getReplyHeaderMessage(String senderId, Date date, String message) {
List<String> toPass = new ArrayList<String>();
toPass.add(senderId);
List<GenericItemBean> theSender = getUsersbyUserId(toPass);
String senderFullName = senderId;
if (theSender != null && !theSender.isEmpty())
senderFullName = theSender.get(0).getAlternativeName();
String toReturn = "\n\n---\n on " + date + " " + senderFullName + " wrote:";
toReturn += "\n\n"+message;
return toReturn;
}
/**
* return the User instance given his id
* @param recipientIds