IMAP fix edge case of nested folder filtering of unwanted folders (#17428)
Fixes this edge case I saw on a customer's account, where INBOX was the parent folder of standard folders <img width="580" height="634" alt="edge case folders" src="https://github.com/user-attachments/assets/c715e5c6-8d37-45a8-a962-16da2bf38ced" />
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ export class ImapGetAllFoldersService implements MessageFolderDriver {
|
||||
pathToExternalIdMap.set(mailbox.path, externalId);
|
||||
|
||||
if (this.isValidMailbox(mailbox, folders)) {
|
||||
const standardFolder = getStandardFolderByRegex(mailbox.path);
|
||||
const standardFolder = getStandardFolderByRegex(mailbox.name);
|
||||
|
||||
if (!shouldCreateFolderByDefault(standardFolder)) {
|
||||
continue;
|
||||
|
||||
+14
@@ -141,4 +141,18 @@ describe('getSentFolderCandidatesByRegex', () => {
|
||||
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it('matches Sent folder when nested under INBOX', () => {
|
||||
const input: ListResponse[] = [
|
||||
{ path: 'INBOX', name: 'Inbox' } as ListResponse,
|
||||
{ path: 'INBOX/Sent', name: 'Sent' } as ListResponse,
|
||||
{ path: 'INBOX/Archive', name: 'Archive' } as ListResponse,
|
||||
];
|
||||
|
||||
const result = getImapSentFolderCandidatesByRegex(input);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].path).toBe('INBOX/Sent');
|
||||
expect(result[0].name).toBe('Sent');
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ export function getImapSentFolderCandidatesByRegex(
|
||||
const regexCandidateFolders: string[] = [];
|
||||
|
||||
for (const folder of list) {
|
||||
const standardFolder = getStandardFolderByRegex(folder.path);
|
||||
const standardFolder = getStandardFolderByRegex(folder.name);
|
||||
|
||||
if (standardFolder === StandardFolder.SENT) {
|
||||
regexCandidateFolders.push(folder.path);
|
||||
|
||||
Reference in New Issue
Block a user