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 {
Long sent = helper.getSent();
Long received = helper.getReceivedHeader();
Long received = helper.getReceivedHeader(helper.getResent());
if (received == null)
received = sent;
if (received == null)

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

Loading…
Cancel
Save