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:
+4
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user