@remit/mailbox-service 0.0.101 → 0.0.103
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/package.json +1 -1
- package/src/body-sync-auto-read-writeonce.test.ts +3 -3
- package/src/body-sync-calendar-suggestion.test.ts +1 -1
- package/src/body-sync-category-denormalize.test.ts +2 -2
- package/src/body-sync-category-override.test.ts +9 -9
- package/src/body-sync-category-writeonce.test.ts +3 -3
- package/src/body-sync-filter.test.ts +1 -1
- package/src/body-sync-placement-flags.test.ts +1 -1
- package/src/body-sync-placement-writeonce.test.ts +4 -4
- package/src/body-sync-quarantine.test.ts +7 -3
- package/src/body-sync-resync.test.ts +5 -5
- package/src/body-sync-unclassifiable-once.test.ts +6 -2
- package/src/body-sync-unsubscribed-auto-read.test.ts +1 -1
- package/src/body-sync.ts +45 -21
- package/src/classification-backfill.test.ts +72 -0
- package/src/classification-backfill.ts +18 -0
- package/src/classify-message.test.ts +59 -0
- package/src/classify-message.ts +5 -2
- package/src/folder-placement.ts +56 -0
- package/src/heuristics/senderMismatch.test.ts +44 -6
- package/src/heuristics/senderMismatch.ts +10 -4
- package/src/index.ts +6 -0
- package/src/mailbox-management.test.ts +48 -3
- package/src/mailbox-management.ts +25 -0
- package/src/mailbox-queue.ts +7 -5
- package/src/mailbox-sync.test.ts +52 -5
- package/src/mailbox-sync.ts +13 -4
package/src/mailbox-sync.ts
CHANGED
|
@@ -82,6 +82,7 @@ export interface SyncAccountInfo {
|
|
|
82
82
|
export interface MailboxSyncLogger {
|
|
83
83
|
info(obj: Record<string, unknown>, msg: string): void;
|
|
84
84
|
debug(obj: Record<string, unknown>, msg: string): void;
|
|
85
|
+
error(obj: Record<string, unknown>, msg: string): void;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
/**
|
|
@@ -263,13 +264,13 @@ export class MailboxSyncService {
|
|
|
263
264
|
result.updated++;
|
|
264
265
|
}
|
|
265
266
|
} else if (!claimedByPendingRename.has(mailboxInfo.fullPath)) {
|
|
266
|
-
await this.createMailbox(
|
|
267
|
+
const created = await this.createMailbox(
|
|
267
268
|
account.accountId,
|
|
268
269
|
mailboxInfo,
|
|
269
270
|
namespaces,
|
|
270
271
|
connection,
|
|
271
272
|
);
|
|
272
|
-
result.created++;
|
|
273
|
+
if (created) result.created++;
|
|
273
274
|
}
|
|
274
275
|
},
|
|
275
276
|
{ concurrency: 3 },
|
|
@@ -432,7 +433,7 @@ export class MailboxSyncService {
|
|
|
432
433
|
},
|
|
433
434
|
_namespaces: ImapNamespaces,
|
|
434
435
|
connection: IImapConnection,
|
|
435
|
-
): Promise<MailboxItem> => {
|
|
436
|
+
): Promise<MailboxItem | null> => {
|
|
436
437
|
// Fetch mailbox status using STATUS command (doesn't require SELECT/EXAMINE)
|
|
437
438
|
// This gets us message counts including unseen without opening the mailbox
|
|
438
439
|
const status = await connection.getMailboxStatus(mailboxInfo.fullPath);
|
|
@@ -472,7 +473,15 @@ export class MailboxSyncService {
|
|
|
472
473
|
// parentMailboxId would need to be resolved from parentPath
|
|
473
474
|
};
|
|
474
475
|
|
|
475
|
-
const
|
|
476
|
+
const created = await this.mailboxService.create(input);
|
|
477
|
+
if (created.outcome === "PathTaken") {
|
|
478
|
+
this.log.error(
|
|
479
|
+
{ accountId, fullPath: mailboxInfo.fullPath },
|
|
480
|
+
"Sweep found no row for a folder path the account already holds",
|
|
481
|
+
);
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
const { mailbox } = created;
|
|
476
485
|
|
|
477
486
|
// Keep the MailboxSpecialUseEntry table in sync — every backend and worker
|
|
478
487
|
// special-folder lookup reads it through MailboxSpecialUseRepo. Denormalized
|