Commit db0f4e94 by Harsh Shah

Finish Hotfix-20190808

parents 24ab2c55 a3643e17
...@@ -30,7 +30,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant ...@@ -30,7 +30,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
private static final String ACC_USER_NAME = ConfigMgr.getKeyfileString("imap.email.acc.username"); private static final String ACC_USER_NAME = ConfigMgr.getKeyfileString("imap.email.acc.username");
private static final String ACC_PASSWORD = ConfigMgr.getKeyfileString("imap.email.acc.password"); private static final String ACC_PASSWORD = ConfigMgr.getKeyfileString("imap.email.acc.password");
private static final boolean SYNC_ALL_EXISTING_EMAILS = ConfigMgr.getKeyfileBoolean("sync.all.existing.emails", false); private static final boolean SYNC_ALL_EXISTING_EMAILS = ConfigMgr.getKeyfileBoolean("sync.all.existing.emails", false);
private static final Integer SYNC_EMAILS_SINCE_MINUTES = ConfigMgr.getKeyfileInt("sync.emails.since.minutes", 10*24*60); //Applicable only when SYNC_ALL_EXISTING_EMAILS is false. private static final Integer SYNC_EMAILS_SINCE_MINUTES = ConfigMgr.getKeyfileInt("sync.emails.since.minutes", 12*24*60); //Applicable only when SYNC_ALL_EXISTING_EMAILS is false.
public static final LoggingArea LOG = LoggingArea.createLoggingArea("PerformaEmailFetcher"); public static final LoggingArea LOG = LoggingArea.createLoggingArea("PerformaEmailFetcher");
@Override @Override
...@@ -85,7 +85,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant ...@@ -85,7 +85,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
for (Folder folder : folders) for (Folder folder : folders)
{ {
if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0 && folder.getFullName().equalsIgnoreCase("INBOX"))
{ {
LogMgr.log(LOG, LogLevel.PROCESSING1, "Processing folder " + folder.getFullName()); LogMgr.log(LOG, LogLevel.PROCESSING1, "Processing folder " + folder.getFullName());
visitedNodes.add(folder.getFullName()); visitedNodes.add(folder.getFullName());
...@@ -229,6 +229,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant ...@@ -229,6 +229,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
LogMgr.log(LOG, LogLevel.PROCESSING2 , "processMessage called"); LogMgr.log(LOG, LogLevel.PROCESSING2 , "processMessage called");
String tmpFromAdress = null; String tmpFromAdress = null;
String tmpFromPerson = null;
String tmpReplyTo = null; String tmpReplyTo = null;
String tmpFirstName = null; String tmpFirstName = null;
String tmpLastName = null; String tmpLastName = null;
...@@ -265,20 +266,30 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant ...@@ -265,20 +266,30 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
tmpSubject = message.getSubject(); tmpSubject = message.getSubject();
tmpSentDate = message.getReceivedDate(); tmpSentDate = message.getReceivedDate();
tmpMessageID = ((MimeMessage)message).getMessageID(); tmpMessageID = ((MimeMessage)message).getMessageID();
tmpMessageBody = EmailFetcher.getText(message, new ArrayList());
if(message.getReplyTo() != null && message.getReplyTo().length > 0) if(message.getReplyTo() != null && message.getReplyTo().length > 0)
{ {
tmpReplyTo = ((InternetAddress) message.getReplyTo()[0]).getAddress(); tmpReplyTo = ((InternetAddress) message.getReplyTo()[0]).getAddress();
String name = ((InternetAddress) message.getReplyTo()[0]).getPersonal(); tmpFromPerson = ((InternetAddress) message.getReplyTo()[0]).getPersonal();
if(tmpReplyTo != null && tmpReplyTo.equals("noreply@jobapplications.seek.com.au"))
{
tmpFromPerson = getApplicantName(tmpFromPerson);
Document document = Jsoup.parse(tmpMessageBody);
Element atag = document.select("a[title*=Email]").first();
tmpReplyTo = atag.text();
}
tmpFirstName = getFirstName(name); tmpFirstName = formatName(getFirstName(tmpFromPerson));
tmpLastName = getLastName(name); tmpLastName = formatName(getLastName(tmpFromPerson));
} }
LogMgr.log(LOG, LogLevel.PROCESSING2 , "Mail Subject:" + tmpSubject, " Address:", tmpFromAdress, " MessageId:", tmpMessageID); LogMgr.log(LOG, LogLevel.PROCESSING2 , "Mail Subject:" + tmpSubject, " Address:", tmpFromAdress, " MessageId:", tmpMessageID);
LogMgr.log(LOG, LogLevel.PROCESSING2 , "Mail Details: Received ", message.getReceivedDate(), " Sent:", message.getSentDate()); LogMgr.log(LOG, LogLevel.PROCESSING2 , "Mail Details: Received ", message.getReceivedDate(), " Sent:", message.getSentDate());
if(message.getAllRecipients() != null && message.getAllRecipients().length > 0) if(message.getAllRecipients() != null && message.getAllRecipients().length > 0)
{ {
for(Address receipientAddress : message.getAllRecipients()) for(Address receipientAddress : message.getAllRecipients())
...@@ -300,7 +311,6 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant ...@@ -300,7 +311,6 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
tmpEmailText = EmailFetcher.getText(message, new ArrayList<>()); tmpEmailText = EmailFetcher.getText(message, new ArrayList<>());
tmpContents = getAttachments(message); tmpContents = getAttachments(message);
tmpMessageBody = EmailFetcher.getText(message, new ArrayList());
} }
catch (MessagingException | IOException ex) catch (MessagingException | IOException ex)
{ {
...@@ -351,7 +361,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant ...@@ -351,7 +361,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
// handle seek email // handle seek email
if(replyTo == null || replyTo.isEmpty()) if(replyTo == null || replyTo.isEmpty())
{ {
// might have to check email body if reply to is not set // email body is checked - retriving a tag with title="Email applicant name"
return; return;
} }
...@@ -543,11 +553,21 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant ...@@ -543,11 +553,21 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
return ((name.split("\\w+").length > 1) && (name.lastIndexOf(' ') > 0 )) ? name.substring(name.lastIndexOf(" ")+1) : ""; return ((name.split("\\w+").length > 1) && (name.lastIndexOf(' ') > 0 )) ? name.substring(name.lastIndexOf(" ")+1) : "";
} }
private static String formatName(String name)
{
return name.length() > 1 ? name.substring(0,1).toUpperCase() + name.substring(1).toLowerCase() : name;
}
public static String getJobIdentifierFromEmail(String strReceipient) public static String getJobIdentifierFromEmail(String strReceipient)
{ {
int index = strReceipient.indexOf('@'); int index = strReceipient.indexOf('@');
return strReceipient.substring(0, index).replace("job", ""); return strReceipient.substring(0, index).replace("job", "");
}
public static String getApplicantName(String strPerson)
{
return strPerson.replace("via SEEK", "").trim();
} }
private static List<FileBinaryContent> getAttachments(Message message) throws IOException, MessagingException private static List<FileBinaryContent> getAttachments(Message message) throws IOException, MessagingException
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<TASK factory="Participant" class="oneit.appservices.batch.DefaultTask"> <TASK factory="Participant" class="oneit.appservices.batch.DefaultTask">
<RUN class="performa.utils.PerformaEmailFetcher" factory="Participant"> <RUN class="performa.utils.PerformaEmailFetcher" factory="Participant">
</RUN> </RUN>
<WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch"> <WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.emailfetch">
<NODE name="schedule" class="oneit.appservices.batch.QuickSchedule"> <NODE name="schedule" class="oneit.appservices.batch.QuickSchedule">
<NODE name="period" factory="Integer" value="5"/> <NODE name="period" factory="Integer" value="5"/>
</NODE> </NODE>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment