Add conversation threads and prepare 0.6.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-11-17 22:46:11 +02:00
co-authored by Copilot
parent 93ff651e9d
commit bb34eedb44
38 changed files with 532 additions and 23 deletions
@@ -166,6 +166,9 @@ internal object AndroidMailService {
add(FetchProfile.Item.FLAGS)
add(FetchProfile.Item.CONTENT_INFO)
add(UIDFolder.FetchProfileItem.UID)
add("Message-ID")
add("In-Reply-To")
add("References")
}
folder.fetch(batch.toTypedArray(), profile)
val snoozed = account.optJSONArray("snoozedMessages") ?: JSONArray()
@@ -380,6 +383,11 @@ internal object AndroidMailService {
message.sentDate = Date()
message.saveChanges()
input.optString("messageId").takeIf(String::isNotBlank)?.let { message.setHeader("Message-ID", it) }
val idPattern = Regex("<[\\x21-\\x3b\\x3d\\x3f-\\x7e]+@[\\x21-\\x3b\\x3d\\x3f-\\x7e]+>")
val parent = idPattern.find(input.optString("inReplyTo").take(254))?.value
val references = idPattern.findAll(input.optString("references").take(900)).map { it.value }.toList()
if (parent != null) message.setHeader("In-Reply-To", parent)
if (references.isNotEmpty()) message.setHeader("References", references.joinToString(" "))
}
val transport = session.getTransport("smtp")
@@ -750,6 +758,9 @@ internal object AndroidMailService {
.put("sender", senderName)
.put("email", senderEmail)
.put("subject", subject)
.put("messageId", message.getHeader("Message-ID")?.joinToString(" ") ?: "")
.put("inReplyTo", message.getHeader("In-Reply-To")?.joinToString(" ") ?: "")
.put("references", message.getHeader("References")?.joinToString(" ") ?: "")
.put("snippet", snippet)
.put("encrypted", encrypted)
.put("signed", signed)
@@ -830,6 +830,8 @@ class EpMailPlugin : Plugin() {
.put("cc", input.optString("cc").take(4000))
.put("subject", input.optString("subject").take(998))
.put("text", input.optString("text").take(500000))
.put("inReplyTo", input.optString("inReplyTo").take(254))
.put("references", input.optString("references").take(900))
.put("attachments", input.optJSONArray("attachments") ?: JSONArray())
.put("updatedAt", System.currentTimeMillis())
AndroidAccountVault.saveDraft(account.optString("id"), draft)