add IMAP write operations, special folder role detection

Extend IMAPClientProtocol with storeFlags, moveMessage, copyMessage,
expunge, appendMessage, capabilities methods. Implement all six in
IMAPClient actor using NIOIMAPCore typed commands. Add multi-part
command support to IMAPConnection/IMAPCommandRunner for APPEND.
MockIMAPClient tracks all write calls for testing. SyncCoordinator
detects mailbox roles from LIST attributes with name-based fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-14 05:12:58 +01:00
parent d659ed67de
commit 427f197bb3
6 changed files with 285 additions and 0 deletions
@@ -18,4 +18,22 @@ struct IMAPCommandRunner {
let tagged = TaggedCommand(tag: tag, command: command)
return try await connection.sendCommand(tag, command: .tagged(tagged))
}
mutating func runAppend(_ parts: [AppendCommand]) async throws -> [Response] {
let tag = nextTag()
var streamParts: [CommandStreamPart] = []
for (index, part) in parts.enumerated() {
if index == 0 {
// Replace the start command's tag with our generated tag
if case .start(_, let mailbox) = part {
streamParts.append(.append(.start(tag: tag, appendingTo: mailbox)))
} else {
streamParts.append(.append(part))
}
} else {
streamParts.append(.append(part))
}
}
return try await connection.sendMultiPartCommand(tag, parts: streamParts)
}
}