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
@@ -1,3 +1,5 @@
import Foundation
public protocol IMAPClientProtocol: Sendable {
func connect() async throws
func disconnect() async throws
@@ -6,4 +8,12 @@ public protocol IMAPClientProtocol: Sendable {
func fetchEnvelopes(uidsGreaterThan uid: Int) async throws -> [FetchedEnvelope]
func fetchFlags(uids: ClosedRange<Int>) async throws -> [UIDFlagsPair]
func fetchBody(uid: Int) async throws -> (text: String?, html: String?)
// v0.3 write operations
func storeFlags(uid: Int, mailbox: String, add: [String], remove: [String]) async throws
func moveMessage(uid: Int, from: String, to: String) async throws
func copyMessage(uid: Int, from: String, to: String) async throws
func expunge(mailbox: String) async throws
func appendMessage(to mailbox: String, message: Data, flags: [String]) async throws
func capabilities() async throws -> Set<String>
}