Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #35 from asutherland/hoodiecrow-folder-config
Browse files Browse the repository at this point in the history
Bug 1178197 - Make underInbox work correctly for hoodiecrow.  Speculative merge; the gaia-email-libs-and-more review is where this code will be used or not.
  • Loading branch information
asutherland committed Nov 4, 2015
2 parents 3caf96e + 43eb6b3 commit 3538e05
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions run_hoodiecrow.js
Expand Up @@ -157,6 +157,10 @@ function updateCredentials(obj) {
* the legacy imapd logic, but we should probably just change to directly
* propagating the structure directly to what hoodiecrow consumes once we
* need to make a significant change to this.
*
* NOTE: It turns out hoodiecrow has some (known, admitted) awkwardness with
* how it handles the INBOX folder and namespaces. This should all be
* overhauled in conjunction with improving upstream hoodiecrow.
*/
function makeFolderStorage(modeOrConfig) {
var mode, folderDefs;
Expand Down Expand Up @@ -190,14 +194,16 @@ function makeFolderStorage(modeOrConfig) {
};
} else if (mode === 'underinbox') {
return {
'INBOX': {},
'': { // documentme: why is the personal namespace still under ''?
'INBOX': {
},
'INBOX/': { // documentme: why is the personal namespace still under ''?
type: 'personal',
separator: '/',
folders: {
'INBOX/Drafts': { 'special-use': '\\Drafts' },
'INBOX/Sent': { 'special-use': '\\Sent' },
'INBOX/Trash': { 'special-use': '\\Trash' },
'INBOX/Custom': { }
'Drafts': { 'special-use': '\\Drafts' },
'Sent': { 'special-use': '\\Sent' },
'Trash': { 'special-use': '\\Trash' },
'Custom': { }
}
}
};
Expand All @@ -211,13 +217,23 @@ function makeFolderStorage(modeOrConfig) {
foldersByPath[folderDef.name] = meta;
});

return {
'INBOX': {},
'': { // (implied personal namespace)
var storage = {
'INBOX': {}
};

if (modeOrConfig.underInbox) {
storage['INBOX/'] = {
type: 'personal',
separator: '/',
folders: foldersByPath
}
};
};
} else {
storage[''] = {
separator: '/',
folders: foldersByPath
};
}
return storage;
};
}

Expand Down Expand Up @@ -290,7 +306,9 @@ function handleRequest(msg) {
case 'moveSystemFoldersUnderneathInbox':
imapServer.folderCache = {};
imapServer.storage = makeFolderStorage('underinbox');

// indexFolders is not intended to be used multiple times, irrevocably
// mutating referenceNamespace, so we need to reset it here.
imapServer.referenceNamespace = false;
imapServer.indexFolders();
break;
}
Expand Down

0 comments on commit 3538e05

Please sign in to comment.