Fix detect_drafts_folder using non-existent imapclient.DRAFTS constant

imapclient.DRAFTS does not exist (only imapclient.DRAFT, which is a
message flag, not a folder attribute). Replaced with direct list_folders
iteration checking for the \Drafts special-use flag, matching the
approach used by detect_archive_folder.
This commit is contained in:
Kacper Kwapisz
2026-03-24 16:16:26 +01:00
parent 772e6bc995
commit 7d38b7ed81
+4 -5
View File
@@ -353,11 +353,10 @@ def detect_archive_folder(client: IMAPClient) -> str:
def detect_drafts_folder(client: IMAPClient) -> str:
import imapclient as imc
result = client.find_special_folder(imc.DRAFTS)
if result:
return result
folders = client.list_folders()
for flags, _delim, name in folders:
if b"\\Drafts" in flags:
return name
for name in ("Drafts", "[Gmail]/Drafts", "INBOX.Drafts"):
if client.folder_exists(name):
return name