POP3: get received time before resend time

pull/204/head
M66B 3 years ago
parent c820e15a42
commit c085fcacf7

@ -2476,7 +2476,7 @@ class Core {
try { try {
Long sent = helper.getSent(); Long sent = helper.getSent();
Long received = helper.getReceivedHeader(); Long received = helper.getReceivedHeader(helper.getResent());
if (received == null) if (received == null)
received = sent; received = sent;
if (received == null) if (received == null)

@ -1557,6 +1557,10 @@ public class MessageHelper {
} }
Long getReceivedHeader() throws MessagingException { Long getReceivedHeader() throws MessagingException {
return getReceivedHeader(null);
}
Long getReceivedHeader(Long before) throws MessagingException {
ensureHeaders(); ensureHeaders();
// https://tools.ietf.org/html/rfc5321#section-4.4 // https://tools.ietf.org/html/rfc5321#section-4.4
@ -1565,17 +1569,24 @@ public class MessageHelper {
if (received == null || received.length == 0) if (received == null || received.length == 0)
return null; return null;
String last = MimeUtility.unfold(received[0]); // First header is last added header
int semi = last.lastIndexOf(';'); for (int i = 0; i < received.length; i++) {
if (semi < 0) String header = MimeUtility.unfold(received[i]);
return null; int semi = header.lastIndexOf(';');
if (semi < 0)
return null;
MailDateFormat mdf = new MailDateFormat(); MailDateFormat mdf = new MailDateFormat();
Date date = mdf.parse(last, new ParsePosition(semi + 1)); Date date = mdf.parse(header, new ParsePosition(semi + 1));
if (date == null) if (date == null)
return null; return null;
return date.getTime(); long time = date.getTime();
if (before == null || time < before)
return time;
}
return null;
} }
Long getSent() throws MessagingException { Long getSent() throws MessagingException {
@ -1588,6 +1599,21 @@ public class MessageHelper {
return sent.getTime(); return sent.getTime();
} }
Long getResent() throws MessagingException {
ensureHeaders();
String resent = imessage.getHeader("Resent-Date", null);
if (resent == null)
return null;
MailDateFormat mdf = new MailDateFormat();
Date date = mdf.parse(resent, new ParsePosition(0));
if (date == null)
return null;
return date.getTime();
}
String getHeaders() throws MessagingException { String getHeaders() throws MessagingException {
ensureHeaders(); ensureHeaders();

Loading…
Cancel
Save