@bobfrankston/mailx-imap 0.1.90 → 0.1.91
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/index.js +24 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3590,6 +3590,30 @@ export class ImapManager extends EventEmitter {
|
|
|
3590
3590
|
}
|
|
3591
3591
|
break;
|
|
3592
3592
|
}
|
|
3593
|
+
case "copy": {
|
|
3594
|
+
const target = folders.find(f => f.id === action.targetFolderId);
|
|
3595
|
+
if (!target) {
|
|
3596
|
+
console.error(` [sync] Copy target folder ${action.targetFolderId} missing — dropping action UID ${action.uid}`);
|
|
3597
|
+
throw new Error(`copy target folder ${action.targetFolderId} not found`);
|
|
3598
|
+
}
|
|
3599
|
+
// Copy = fetch the raw message and APPEND it to the
|
|
3600
|
+
// target; it stays in the source folder too. The
|
|
3601
|
+
// compat client has no native IMAP COPY, but
|
|
3602
|
+
// fetch+append is equivalent and reuses existing
|
|
3603
|
+
// primitives. The new copy is pulled into the local
|
|
3604
|
+
// store by a target-folder sync below.
|
|
3605
|
+
const msg = await client.fetchMessageByUid(folder.path, action.uid, { source: true });
|
|
3606
|
+
if (!msg || !msg.source) {
|
|
3607
|
+
console.log(` [sync] Copy UID ${action.uid} in ${folder.path}: message gone (attempt ${action.attempts + 1}); dropping action`);
|
|
3608
|
+
break;
|
|
3609
|
+
}
|
|
3610
|
+
const copyFlags = (msg.flags || []).filter((f) => f !== "\\Recent");
|
|
3611
|
+
await client.appendMessage(target.path, msg.source, copyFlags);
|
|
3612
|
+
console.log(` [sync] Copied UID ${action.uid}: ${folder.path} → ${target.path}`);
|
|
3613
|
+
// Import the new copy so it appears in the target folder.
|
|
3614
|
+
this.syncFolder(accountId, target.id).catch(() => { });
|
|
3615
|
+
break;
|
|
3616
|
+
}
|
|
3593
3617
|
}
|
|
3594
3618
|
// Success: the local action reached the server. Lift the
|
|
3595
3619
|
// in-flight delete/move suppression so the destination
|