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:
|
def detect_drafts_folder(client: IMAPClient) -> str:
|
||||||
import imapclient as imc
|
folders = client.list_folders()
|
||||||
|
for flags, _delim, name in folders:
|
||||||
result = client.find_special_folder(imc.DRAFTS)
|
if b"\\Drafts" in flags:
|
||||||
if result:
|
return name
|
||||||
return result
|
|
||||||
for name in ("Drafts", "[Gmail]/Drafts", "INBOX.Drafts"):
|
for name in ("Drafts", "[Gmail]/Drafts", "INBOX.Drafts"):
|
||||||
if client.folder_exists(name):
|
if client.folder_exists(name):
|
||||||
return name
|
return name
|
||||||
|
|||||||
Reference in New Issue
Block a user