@bobfrankston/iflow-direct 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/imap-compat.js +35 -14
- package/package.json +1 -1
package/imap-compat.js
CHANGED
|
@@ -73,24 +73,45 @@ export class CompatImapClient {
|
|
|
73
73
|
}
|
|
74
74
|
/** Detect special folders from folder list */
|
|
75
75
|
getSpecialFolders(folders) {
|
|
76
|
+
// Match IMAP special-use flags (RFC 6154) first, then fall back to exact
|
|
77
|
+
// LEAF NAME match. Do NOT use substring matches on the full path —
|
|
78
|
+
// "Drafts.Older" used to get tagged as the Drafts folder because of a
|
|
79
|
+
// lower.includes("draft") test, which made it impossible to rename or
|
|
80
|
+
// delete the subfolder.
|
|
76
81
|
const result = {};
|
|
82
|
+
const leafName = (f) => {
|
|
83
|
+
const delim = f.delimiter || ".";
|
|
84
|
+
return (f.path.split(delim).pop() || f.path).toLowerCase();
|
|
85
|
+
};
|
|
77
86
|
for (const f of folders) {
|
|
78
|
-
const
|
|
87
|
+
const name = leafName(f);
|
|
79
88
|
const flags = f.flags.map(fl => fl.toLowerCase());
|
|
80
|
-
if (flags.includes("\\inbox") ||
|
|
81
|
-
result.inbox
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
else if (flags.includes("\\
|
|
85
|
-
result.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
else if (flags.includes("\\
|
|
89
|
-
result.
|
|
90
|
-
|
|
89
|
+
if (flags.includes("\\inbox") || name === "inbox") {
|
|
90
|
+
if (!result.inbox)
|
|
91
|
+
result.inbox = f.path;
|
|
92
|
+
}
|
|
93
|
+
else if (flags.includes("\\sent") || name === "sent" || name === "sent items" || name === "sent mail") {
|
|
94
|
+
if (!result.sent)
|
|
95
|
+
result.sent = f.path;
|
|
96
|
+
}
|
|
97
|
+
else if (flags.includes("\\trash") || name === "trash" || name === "deleted items" || name === "deleted") {
|
|
98
|
+
if (!result.trash)
|
|
99
|
+
result.trash = f.path;
|
|
100
|
+
}
|
|
101
|
+
else if (flags.includes("\\drafts") || name === "drafts" || name === "draft") {
|
|
102
|
+
if (!result.drafts)
|
|
103
|
+
result.drafts = f.path;
|
|
104
|
+
}
|
|
105
|
+
else if (flags.includes("\\junk") || flags.includes("\\spam") || name === "spam" || name === "junk" || name === "junk email" || name === "junk e-mail") {
|
|
106
|
+
if (!result.junk)
|
|
107
|
+
result.junk = f.path;
|
|
108
|
+
if (!result.spam)
|
|
109
|
+
result.spam = f.path;
|
|
110
|
+
}
|
|
111
|
+
else if (flags.includes("\\archive") || name === "archive" || name === "archives") {
|
|
112
|
+
if (!result.archive)
|
|
113
|
+
result.archive = f.path;
|
|
91
114
|
}
|
|
92
|
-
else if (flags.includes("\\archive") || lower === "archive")
|
|
93
|
-
result.archive = f.path;
|
|
94
115
|
}
|
|
95
116
|
return result;
|
|
96
117
|
}
|