add fetchFullMessage, fetchSection to IMAPClient for MIME attachment retrieval

This commit is contained in:
2026-03-14 13:31:38 +01:00
parent 0a564a05fd
commit 968dd91f80
4 changed files with 97 additions and 0 deletions
@@ -22,6 +22,10 @@ final class MockIMAPClient: IMAPClientProtocol, @unchecked Sendable {
var expungedMailboxes: [String] = []
var appendedMessages: [(mailbox: String, message: Data, flags: [String])] = []
var serverCapabilities: Set<String> = ["IMAP4rev1", "MOVE"]
var fullMessages: [Int: String] = [:]
var sections: [String: Data] = [:] // key: "uid-section"
var fetchFullMessageCalls: [Int] = []
var fetchSectionCalls: [(uid: Int, mailbox: String, section: String)] = []
func connect() async throws {
connectCalled = true
@@ -61,6 +65,18 @@ final class MockIMAPClient: IMAPClientProtocol, @unchecked Sendable {
bodies[uid] ?? (nil, nil)
}
// MARK: - v0.5 attachment/MIME operations
func fetchFullMessage(uid: Int) async throws -> String {
fetchFullMessageCalls.append(uid)
return fullMessages[uid] ?? ""
}
func fetchSection(uid: Int, mailbox: String, section: String) async throws -> Data {
fetchSectionCalls.append((uid: uid, mailbox: mailbox, section: section))
return sections["\(uid)-\(section)"] ?? Data()
}
// MARK: - v0.3 write operations
func storeFlags(uid: Int, mailbox: String, add: [String], remove: [String]) async throws {