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
+6 -1
View File
@@ -267,7 +267,7 @@ function createPgpMail({ keyStore, cache }) {
},
// Builds a complete RFC 3156 message. Returns { raw, envelope }.
async build({ from, to, cc, subject, text, messageId, date = new Date(), encrypt, sign, passphrase, signerFingerprint, attachments = [] }) {
async build({ from, to, cc, subject, text, messageId, inReplyTo, references, date = new Date(), encrypt, sign, passphrase, signerFingerprint, attachments = [] }) {
const toList = parseAddresses(to);
const ccList = parseAddresses(cc);
if (!toList.length) throw new Error('Add at least one recipient.');
@@ -290,6 +290,9 @@ function createPgpMail({ keyStore, cache }) {
}
await cache.remember(signerEntry.fingerprint, secret);
}
const { messageIds } = require('../conversation-threads.js');
const parentIds = messageIds(inReplyTo).slice(0, 1);
const referenceIds = messageIds(references);
const headers = [
`From: ${formatAddress(from)}`,
`To: ${toList.map(formatAddress).join(', ')}`,
@@ -297,6 +300,8 @@ function createPgpMail({ keyStore, cache }) {
`Subject: ${encodeHeader(subject || '(no subject)')}`,
`Date: ${date.toUTCString().replace('GMT', '+0000')}`,
`Message-ID: ${String(messageId).replace(/[\r\n<>\s]/g, '').replace(/^/, '<').replace(/$/, '>')}`,
...parentIds.map(id => `In-Reply-To: ${id}`),
...(referenceIds.length ? [`References: ${referenceIds.join(' ')}`] : []),
'MIME-Version: 1.0'
];
const inner = await innerEntity(text, attachments);