import type { IThreadMessageRepository } from "@remit/data-ports"; import type { ProcessContext } from "../context.js"; import type { MessageDeleteEvent } from "../events.js"; /** * Delete every ThreadMessage row that points at this messageId. * * A single Message can have multiple ThreadMessage rows — one per mailbox * the message exists in (e.g. INBOX + a label/folder copy). Permanent-delete * cleanup must remove ALL of them; using `findByMessageId` (single row) leaves * orphan rows in other mailboxes that then leak into their listings. See * issue #212. */ export declare const deleteAllThreadMessagesForMessage: (threadMessageService: Pick, accountConfigId: string, messageId: string) => Promise; /** * Settle a move to Trash the server left unconfirmed, by asking it two * read-only questions instead of one. Both handles wrap the SAME connection but * are scoped to their own mailbox: a `guardConnectionCursor` wrap binds its * checks to the ONE mailbox snapshot it was built with, so the destination must * never be opened through the source's guard. * * The source is asked first, and a source that still holds the uid ends it: the * MOVE did not happen, so nothing at the destination can be this message. The * gate survives #1122's switch to the highest matching uid and is not made * redundant by it — highest picks the fresh copy out of several only once a * fresh copy exists, and where the MOVE never ran every hit at the destination * is an older copy of the same Message-ID (a sieve `fileinto` + `keep`, a * multi-label store, a resend) that `deriveMessageId` folds into this one local * row. An ungated probe hands back that copy's uid, and Empty Trash then * expunges by it. The gate also closes the second half of #912: an empty * `uidMap` can mean the MOVE matched nothing at all. * * A row with no `messageIdHeader`, and a row that is already deleted, have * nothing to probe with; they are distinct verdicts because no redelivery can * change either answer. */ export type TrashMoveConfirmation = { outcome: "confirmed"; uid: number; } | { outcome: "still-at-source"; } | { outcome: "row-gone"; } | { outcome: "unprobeable"; } | { outcome: "unconfirmed"; }; /** * Handle MESSAGE_DELETE events. * Either moves to Trash (IMAP MOVE) or permanently deletes (IMAP DELETE). * * A failing delete retries on redelivery until `receiveCount` reaches * the `config.attempts.messageDelete` budget, at which point * {@link resolveExhaustedMessageDeleteFailure} asks IMAP where the message * actually is and settles the row into one terminal outcome (issue #980). */ export declare const handleMessageDelete: (event: MessageDeleteEvent, ctx: ProcessContext, receiveCount: number) => Promise;