Implement support for replies
This commit is contained in:
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user