Add conversation threads and prepare 0.6.0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -202,6 +202,8 @@ registerIpcHandler('mail:save-draft', async (_event, input) => {
|
||||
cc: String(input?.cc || '').slice(0, 4000),
|
||||
subject: String(input?.subject || '').slice(0, 998),
|
||||
text: String(input?.text || '').slice(0, 500000),
|
||||
inReplyTo: String(input?.inReplyTo || '').slice(0, 254),
|
||||
references: String(input?.references || '').slice(0, 900),
|
||||
attachments: serializeOutgoingAttachments(normalizeOutgoingAttachments(input?.attachments)),
|
||||
updatedAt: Date.now()
|
||||
};
|
||||
@@ -341,6 +343,8 @@ registerIpcHandler('mail:send', async (event, message) => {
|
||||
text: message.text,
|
||||
displayName: message.displayName,
|
||||
messageId: message.messageId || `<${randomUUID()}@ep-mail.local>`,
|
||||
inReplyTo: message.inReplyTo,
|
||||
references: message.references,
|
||||
attachments: message.attachments
|
||||
};
|
||||
const attachments = normalizeOutgoingAttachments(message?.attachments);
|
||||
@@ -376,6 +380,8 @@ registerIpcHandler('mail:send', async (event, message) => {
|
||||
subject: String(queuedMessage.subject || '(no subject)').slice(0, 998),
|
||||
text: signature ? `${body}${body.trim() ? '\n\n' : ''}${signature}`.slice(0, 505000) : body,
|
||||
messageId: queuedMessage.messageId,
|
||||
inReplyTo: queuedMessage.inReplyTo,
|
||||
references: queuedMessage.references,
|
||||
encrypt: Boolean(pgpOptions.encrypt),
|
||||
sign: Boolean(pgpOptions.sign),
|
||||
passphrase: typeof pgpOptions.passphrase === 'string' && pgpOptions.passphrase ? pgpOptions.passphrase : null,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const { randomUUID } = require('node:crypto');
|
||||
const nodemailer = require('nodemailer');
|
||||
const { normalizeOutgoingAttachments } = require('../mail-attachments.cjs');
|
||||
const { messageIds } = require('../../conversation-threads.js');
|
||||
|
||||
function createMailSender({ smtpTransport, imapClient, findSentMailbox, createTransport = nodemailer.createTransport }) {
|
||||
async function sendMailNow(account, message) {
|
||||
@@ -19,6 +20,8 @@ function createMailSender({ smtpTransport, imapClient, findSentMailbox, createTr
|
||||
subject: String(message.subject || '(no subject)').slice(0, 998),
|
||||
text: signature ? `${body}${body.trim() ? '\n\n' : ''}${signature}`.slice(0, 505000) : body,
|
||||
messageId: sentMessageId,
|
||||
inReplyTo: messageIds(message.inReplyTo)[0] || undefined,
|
||||
references: messageIds(message.references),
|
||||
attachments: attachments.map(file => ({
|
||||
filename: file.filename,
|
||||
contentType: file.contentType,
|
||||
|
||||
@@ -344,6 +344,9 @@ async function toUiMessage(item, folder) {
|
||||
sender: sender?.name || sender?.address || 'Unknown sender',
|
||||
email: sender?.address || '',
|
||||
subject: parsed.subject || '(no subject)',
|
||||
messageId: parsed.messageId || '',
|
||||
inReplyTo: parsed.inReplyTo || '',
|
||||
references: parsed.references || [],
|
||||
snippet: encrypted ? 'Encrypted message' : (bodyText || parsed.subject || '').replace(/\s+/g, ' ').slice(0, 180),
|
||||
encrypted,
|
||||
pgpSignatures,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -53,6 +53,7 @@ const objectFieldSchemas = {
|
||||
'mail:create-folder': [{ name: str(100) }],
|
||||
'mail:save-draft': [{
|
||||
id: str(256), to: str(4000), cc: str(4000), subject: str(998), text: str(500_000),
|
||||
inReplyTo: str(254), references: str(900),
|
||||
attachments: array(record(attachmentFields))
|
||||
}],
|
||||
'mail:set-snooze': [{
|
||||
@@ -67,7 +68,7 @@ const objectFieldSchemas = {
|
||||
'mail:preview-attachment': [{ uid: num({ integer: true, min: 1 }), folder: str(256), filename: str(1000) }],
|
||||
'mail:send': [{
|
||||
to: str(4000), cc: str(4000), subject: str(998), text: str(500_000), displayName: str(80),
|
||||
messageId: str(998), attachments: array(record(attachmentFields)),
|
||||
messageId: str(998), inReplyTo: str(254), references: str(900), attachments: array(record(attachmentFields)),
|
||||
pgp: record({ encrypt: bool(), sign: bool(), passphrase: str(4096, { nullable: true }) }, { nullable: true })
|
||||
}],
|
||||
'pgp:generate': [{ name: str(200), email: str(320), passphrase: str(4096), accountId: str(256, { nullable: true }) }],
|
||||
@@ -115,7 +116,7 @@ const positionalFieldSchemas = {
|
||||
'pgp:remove-key-server': { 0: str(256) }
|
||||
};
|
||||
|
||||
const sendMessageFields = new Set(['to', 'cc', 'subject', 'text', 'displayName', 'messageId', 'attachments', 'pgp']);
|
||||
const sendMessageFields = new Set(['to', 'cc', 'subject', 'text', 'displayName', 'messageId', 'inReplyTo', 'references', 'attachments', 'pgp']);
|
||||
|
||||
const schemas = {
|
||||
'app:get-version': [],
|
||||
|
||||
Reference in New Issue
Block a user