Skip to content

Commit

Permalink
fix(special-use): support custom special use flags for the Archive fo…
Browse files Browse the repository at this point in the history
…lder
  • Loading branch information
andris9 committed Oct 26, 2023
1 parent d48d0d8 commit 17aa6a8
Show file tree
Hide file tree
Showing 4 changed files with 1,134 additions and 852 deletions.
6 changes: 5 additions & 1 deletion lib/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ module.exports = async (connection, reference, mailbox, options) => {
let specialUseHints = {};
if (options.specialUseHints && typeof options.specialUseHints === 'object') {
for (let type of Object.keys(options.specialUseHints)) {
if (['sent', 'junk', 'trash', 'drafts'].includes(type) && options.specialUseHints[type] && typeof options.specialUseHints[type] === 'string') {
if (
['sent', 'junk', 'trash', 'drafts', 'archive'].includes(type) &&
options.specialUseHints[type] &&
typeof options.specialUseHints[type] === 'string'
) {
specialUseHints[normalizePath(connection, options.specialUseHints[type])] = `\\${type.replace(/^./, c => c.toUpperCase())}`;
}
}
Expand Down
12 changes: 9 additions & 3 deletions lib/special-use.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ module.exports = {
'الرسائل العشوائية',
'هرزنامه',
'สแปม',
'垃圾郵件',
'垃圾郵件',
'垃圾邮件',
'垃圾電郵'
],
Expand Down Expand Up @@ -275,7 +275,9 @@ module.exports = {
'草稿',
'草稿',
'임시 보관함'
]
],

'\\Archive': ['archive']
},

specialUse(hasSpecialUseExtension, folder) {
Expand All @@ -289,7 +291,11 @@ module.exports = {
}

if (!result || !result.flag) {
let name = folder.name.toLowerCase().trim();
let name = folder.name
.toLowerCase()
.replace(/\u200e/g, '')
.trim();

result = {
flag: Object.keys(module.exports.names).find(flag => module.exports.names[flag].includes(name)),
source: 'name'
Expand Down
Loading

0 comments on commit 17aa6a8

Please sign in to comment.