@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.
@@ -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 mailbox = await this.mailboxService.create(input);
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