1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 02:07:12 +00:00

Simplified references

This commit is contained in:
M66B 2022-07-07 20:57:22 +02:00
parent bf0532c46c
commit ba186235e0

View file

@ -1267,14 +1267,12 @@ public class MessageHelper {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
String refs = imessage.getHeader("References", null); String refs = imessage.getHeader("References", null);
if (refs != null) result.addAll(getReferences(refs));
result.addAll(Arrays.asList(getReferences(refs)));
// Merge references of reported message for threading // Merge references of reported message for threading
InternetHeaders iheaders = getReportHeaders(); InternetHeaders iheaders = getReportHeaders();
if (iheaders != null) { if (iheaders != null) {
String arefs = iheaders.getHeader("References", null); String arefs = iheaders.getHeader("References", null);
if (arefs != null)
for (String ref : getReferences(arefs)) for (String ref : getReferences(arefs))
if (!result.contains(ref)) { if (!result.contains(ref)) {
Log.i("rfc822 ref=" + ref); Log.i("rfc822 ref=" + ref);
@ -1282,7 +1280,7 @@ public class MessageHelper {
} }
String amsgid = iheaders.getHeader("Message-Id", null); String amsgid = iheaders.getHeader("Message-Id", null);
if (amsgid != null) { if (!TextUtils.isEmpty(amsgid)) {
String msgid = MimeUtility.unfold(amsgid); String msgid = MimeUtility.unfold(amsgid);
if (!result.contains(msgid)) { if (!result.contains(msgid)) {
Log.i("rfc822 id=" + msgid); Log.i("rfc822 id=" + msgid);
@ -1294,8 +1292,17 @@ public class MessageHelper {
return result.toArray(new String[0]); return result.toArray(new String[0]);
} }
private String[] getReferences(String header) { private List<String> getReferences(String header) {
return MimeUtility.unfold(header).split("[,\\s]+"); List<String> result = new ArrayList<>();
if (header == null)
return result;
header = MimeUtility.unfold(header);
if (TextUtils.isEmpty(header))
return result;
for (String ref : header.split("[,\\s]+"))
if (!result.contains(ref))
result.add(ref);
return result;
} }
String getDeliveredTo() throws MessagingException { String getDeliveredTo() throws MessagingException {
@ -1325,15 +1332,14 @@ public class MessageHelper {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
String header = imessage.getHeader("In-Reply-To", null); String header = imessage.getHeader("In-Reply-To", null);
if (header != null) result.addAll(getReferences(header));
result.addAll(Arrays.asList(getReferences(header)));
if (result.size() == 0) { if (result.size() == 0) {
// Use reported message ID as synthetic in-reply-to // Use reported message ID as synthetic in-reply-to
InternetHeaders iheaders = getReportHeaders(); InternetHeaders iheaders = getReportHeaders();
if (iheaders != null) { if (iheaders != null) {
header = iheaders.getHeader("Message-Id", null); header = iheaders.getHeader("Message-Id", null);
if (header != null) { if (!TextUtils.isEmpty(header)) {
result.add(header); result.add(header);
Log.i("rfc822 id=" + header); Log.i("rfc822 id=" + header);
} }