From 27c6a3275624817418a1ce952360397f6c23e858 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 28 Dec 2021 09:40:05 +0100 Subject: [PATCH] Report all folders --- app/src/main/java/eu/faircode/email/Core.java | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 70c2d1436b..bbfa95aace 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -3911,31 +3911,32 @@ class Core { if (experiments && helper.isReport()) try { MessageHelper.Report r = parts.getReport(); - - EntityFolder s = db.folder().getFolderByType(folder.account, EntityFolder.SENT); - EntityFolder a = db.folder().getFolderByType(folder.account, EntityFolder.ARCHIVE); - List reported = db.message().getMessagesByMsgId(folder.account, message.inreplyto); - if (reported != null) { - Long f = null; - for (EntityMessage m : reported) - if (s != null && m.folder.equals(s.id)) { - f = null; - break; - } else { - if (f == null || (a != null && a.id.equals(f))) - f = m.folder; - } - if (f != null) - s = db.folder().getFolder(f); - } - - if (r != null && s != null) { + if (r != null) { + String label = null; if (r.isDeliveryStatus()) - EntityOperation.queue(context, s, EntityOperation.REPORT, - message.inreplyto, r.isDelivered() ? "$Delivered" : "$NotDelivered"); + label = (r.isDelivered() ? "$Delivered" : "$NotDelivered"); else if (r.isDispositionNotification()) - EntityOperation.queue(context, s, EntityOperation.REPORT, - message.inreplyto, r.isDisplayed() ? "$Displayed" : "$NotDisplayed"); + label = (r.isDisplayed() ? "$Displayed" : "$NotDisplayed"); + + if (label != null) { + Map map = new HashMap<>(); + + EntityFolder s = db.folder().getFolderByType(folder.account, EntityFolder.SENT); + if (s != null) + map.put(s.id, s); + + List reported = db.message().getMessagesByMsgId(folder.account, message.inreplyto); + if (reported != null) + for (EntityMessage m : reported) + if (!map.containsKey(m.folder)) { + EntityFolder f = db.folder().getFolder(m.folder); + if (f != null) + map.put(f.id, f); + } + + for (EntityFolder f : map.values()) + EntityOperation.queue(context, f, EntityOperation.REPORT, message.inreplyto, label); + } } } catch (Throwable ex) { Log.w(ex);