Add references when deleting attachments

pull/213/head
M66B 1 year ago
parent 43e7f9670d
commit 068034a5f9

@ -2111,7 +2111,11 @@ class Core {
throw new MessageRemovedException(); throw new MessageRemovedException();
String msgid = EntityMessage.generateMessageId(); String msgid = EntityMessage.generateMessageId();
String ref = (TextUtils.isEmpty(message.references)
? message.msgid
: message.references + " " + message.msgid);
MimeMessage icopy = new MimeMessageEx((MimeMessage) imessage, msgid); MimeMessage icopy = new MimeMessageEx((MimeMessage) imessage, msgid);
icopy.addHeader("References", MessageHelper.limitReferences(ref));
MessageHelper helper = new MessageHelper(icopy, context); MessageHelper helper = new MessageHelper(icopy, context);
MessageHelper.MessageParts parts = helper.getMessageParts(); MessageHelper.MessageParts parts = helper.getMessageParts();
List<MessageHelper.AttachmentPart> aparts = parts.getAttachmentParts(); List<MessageHelper.AttachmentPart> aparts = parts.getAttachmentParts();

@ -372,19 +372,8 @@ public class MessageHelper {
imessage.addHeader("Sensitivity", "Company-Confidential"); imessage.addHeader("Sensitivity", "Company-Confidential");
// References // References
if (message.references != null) { if (message.references != null)
// https://tools.ietf.org/html/rfc5322#section-2.1.1 imessage.addHeader("References", limitReferences(message.references));
// Each line of characters MUST be no more than 998 characters ... , excluding the CRLF.
String references = message.references;
int maxlen = MAX_HEADER_LENGTH - "References: ".length();
int sp = references.indexOf(' ');
while (references.length() > maxlen && sp > 0) {
Log.i("Dropping reference=" + references.substring(0, sp));
references = references.substring(sp);
sp = references.indexOf(' ');
}
imessage.addHeader("References", references);
}
if (message.inreplyto != null) if (message.inreplyto != null)
imessage.addHeader("In-Reply-To", message.inreplyto); imessage.addHeader("In-Reply-To", message.inreplyto);
@ -820,6 +809,17 @@ public class MessageHelper {
return new InternetAddress(email, name, StandardCharsets.UTF_8.name()); return new InternetAddress(email, name, StandardCharsets.UTF_8.name());
} }
static String limitReferences(String references) {
int maxlen = MAX_HEADER_LENGTH - "References: ".length();
int sp = references.indexOf(' ');
while (references.length() > maxlen && sp > 0) {
Log.i("Dropping reference=" + references.substring(0, sp));
references = references.substring(sp);
sp = references.indexOf(' ');
}
return references;
}
static Pair<String, String> getExtra(String email, String extra) { static Pair<String, String> getExtra(String email, String extra) {
String name = null; String name = null;
int comma = extra.indexOf(','); int comma = extra.indexOf(',');

Loading…
Cancel
Save