Implement support for replies

This commit is contained in:
2025-01-05 19:55:54 -05:00
parent 834c23735d
commit 1f5889dc39
7 changed files with 64 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ import {AsyncCollection} from "../bones/collection/AsyncCollection.ts";
import {withClient} from "./client.ts";
import {buildThreadAddressMatcher} from "../threads/id.ts";
import {htmlReplyPipeline} from "./sanitize.ts";
import {blake2bHex, blake2sHex} from "blakejs";
export async function getMailboxesToSearch(thread?: string, client?: ImapFlow): Promise<Collection<string>> {
// There are 2 possibilities for where mail might end up.
@@ -102,12 +103,13 @@ export class MailboxIterable extends Iterable<Message> {
.map(x => x.address || '')
.filter(Boolean)
const thread = recipients.map(addr => this.addressMatcher.exec(addr))
.map(result => result?.[1])
const addressMatch = recipients.map(addr => this.addressMatcher.exec(addr))
.filter(Boolean)[0]
const id = `${this.mailbox}.${message.uid}`
return {
id: `${this.mailbox}.${message.uid}`,
id,
idHash: blake2sHex(id, undefined, 8),
date: message.envelope.date,
from: message.envelope.from[0],
subject: message.envelope.subject,
@@ -116,7 +118,8 @@ export class MailboxIterable extends Iterable<Message> {
html: htmlReplyPipeline.apply(source),
recipients,
content,
thread,
thread: addressMatch?.[1],
replyToHash: addressMatch?.[2]?.substring(config.mail.threads.replyPrefix.length),
}
}