Added support for feedback reports

pull/208/head
M66B 3 years ago
parent e2beac7154
commit 6b578217fe

@ -4236,6 +4236,8 @@ class Core {
label = (r.isDelivered() ? MessageHelper.FLAG_DELIVERED : MessageHelper.FLAG_NOT_DELIVERED); label = (r.isDelivered() ? MessageHelper.FLAG_DELIVERED : MessageHelper.FLAG_NOT_DELIVERED);
else if (r.isDispositionNotification()) else if (r.isDispositionNotification())
label = (r.isMdnDisplayed() ? MessageHelper.FLAG_DISPLAYED : MessageHelper.FLAG_NOT_DISPLAYED); label = (r.isMdnDisplayed() ? MessageHelper.FLAG_DISPLAYED : MessageHelper.FLAG_NOT_DISPLAYED);
else if (r.isFeedbackReport())
label = MessageHelper.FLAG_COMPLAINT;
if (label != null) { if (label != null) {
Map<Long, EntityFolder> map = new HashMap<>(); Map<Long, EntityFolder> map = new HashMap<>();

@ -198,6 +198,7 @@ public class MessageHelper {
static final String FLAG_NOT_DELIVERED = "$NotDelivered"; static final String FLAG_NOT_DELIVERED = "$NotDelivered";
static final String FLAG_DISPLAYED = "$Displayed"; static final String FLAG_DISPLAYED = "$Displayed";
static final String FLAG_NOT_DISPLAYED = "$NotDisplayed"; static final String FLAG_NOT_DISPLAYED = "$NotDisplayed";
static final String FLAG_COMPLAINT = "Complaint";
static final String FLAG_LOW_IMPORTANCE = "$LowImportance"; static final String FLAG_LOW_IMPORTANCE = "$LowImportance";
static final String FLAG_HIGH_IMPORTANCE = "$HighImportance"; static final String FLAG_HIGH_IMPORTANCE = "$HighImportance";
@ -1349,7 +1350,8 @@ public class MessageHelper {
ContentType ct = new ContentType(imessage.getContentType()); ContentType ct = new ContentType(imessage.getContentType());
String reportType = ct.getParameter("report-type"); String reportType = ct.getParameter("report-type");
if ("delivery-status".equalsIgnoreCase(reportType) || if ("delivery-status".equalsIgnoreCase(reportType) ||
"disposition-notification".equalsIgnoreCase(reportType)) { "disposition-notification".equalsIgnoreCase(reportType) ||
"feedback-report".equalsIgnoreCase(reportType)) {
MessageParts parts = new MessageParts(); MessageParts parts = new MessageParts();
getMessageParts(null, imessage, parts, null); getMessageParts(null, imessage, parts, null);
for (AttachmentPart apart : parts.attachments) for (AttachmentPart apart : parts.attachments)
@ -2979,7 +2981,9 @@ public class MessageHelper {
boolean isReport() { boolean isReport() {
String ct = contentType.getBaseType(); String ct = contentType.getBaseType();
return Report.isDeliveryStatus(ct) || Report.isDispositionNotification(ct); return (Report.isDeliveryStatus(ct) ||
Report.isDispositionNotification(ct) ||
Report.isFeedbackReport(ct));
} }
} }
@ -3362,6 +3366,11 @@ public class MessageHelper {
w.append(report.disposition); w.append(report.disposition);
} }
if (report.isFeedbackReport()) {
if (!TextUtils.isEmpty(report.feedback))
w.append(report.feedback);
}
if (w.length() > 0) if (w.length() > 0)
warnings.add(w.toString()); warnings.add(w.toString());
} else } else
@ -4294,7 +4303,9 @@ public class MessageHelper {
!Part.ATTACHMENT.equalsIgnoreCase(disposition) && TextUtils.isEmpty(filename)) { !Part.ATTACHMENT.equalsIgnoreCase(disposition) && TextUtils.isEmpty(filename)) {
parts.text.add(new PartHolder(part, contentType)); parts.text.add(new PartHolder(part, contentType));
} else { } else {
if (Report.isDeliveryStatus(ct) || Report.isDispositionNotification(ct)) if (Report.isDeliveryStatus(ct) ||
Report.isDispositionNotification(ct) ||
Report.isFeedbackReport(ct))
parts.extra.add(new PartHolder(part, contentType)); parts.extra.add(new PartHolder(part, contentType));
AttachmentPart apart = new AttachmentPart(); AttachmentPart apart = new AttachmentPart();
@ -4703,6 +4714,7 @@ public class MessageHelper {
String diagnostic; String diagnostic;
String disposition; String disposition;
String refid; String refid;
String feedback;
String html; String html;
Report(String type, String content) { Report(String type, String content) {
@ -4762,6 +4774,15 @@ public class MessageHelper {
this.refid = value; this.refid = value;
break; break;
} }
} else if (isFeedbackReport(type)) {
// https://datatracker.ietf.org/doc/html/rfc5965
feedback = "complaint";
switch (name) {
case "Feedback-Type":
// abuse, fraud, other, virus
feedback = value;
break;
}
} }
} }
} catch (Throwable ex) { } catch (Throwable ex) {
@ -4780,6 +4801,10 @@ public class MessageHelper {
return isDispositionNotification(type); return isDispositionNotification(type);
} }
boolean isFeedbackReport() {
return isFeedbackReport(type);
}
boolean isDelivered() { boolean isDelivered() {
return ("delivered".equals(action) || "relayed".equals(action) || "expanded".equals(action)); return ("delivered".equals(action) || "relayed".equals(action) || "expanded".equals(action));
} }
@ -4839,5 +4864,9 @@ public class MessageHelper {
static boolean isDispositionNotification(String type) { static boolean isDispositionNotification(String type) {
return "message/disposition-notification".equalsIgnoreCase(type); return "message/disposition-notification".equalsIgnoreCase(type);
} }
static boolean isFeedbackReport(String type) {
return "message/feedback-report".equalsIgnoreCase(type);
}
} }
} }

Loading…
Cancel
Save