This commit is contained in:
Expand-sys 2023-02-16 13:58:22 +11:00
parent 4efba37e84
commit aa518c970e
2 changed files with 45 additions and 30 deletions

View file

@ -23,6 +23,18 @@ function sleep(ms) {
}); });
} }
function containsAny(str, substrings) {
for (var i = 0; i != substrings.length; i++) {
var substring = substrings[i];
if (str.indexOf(substring) != - 1) {
return substring;
}
}
return null;
}
async function grabIMAP( async function grabIMAP(
loginSource, loginSource,
loginDest, loginDest,
@ -51,10 +63,9 @@ async function grabIMAP(
return false; return false;
} else { } else {
let arr = source.list() let arr = source.list()
let arr2 = dest.list()
for(let boxes in arr){ for(let boxes in arr){
console.log(boxes) let lock = await source.getMailboxLock(`${boxes}`);
}
let lock = await source.getMailboxLock("INBOX");
const folder = Date.now(); const folder = Date.now();
let parsed; let parsed;
try { try {
@ -73,7 +84,8 @@ async function grabIMAP(
const buf = await Buffer.from( const buf = await Buffer.from(
await fs.readFileSync(path.resolve(__dirname, "./" + id)) await fs.readFileSync(path.resolve(__dirname, "./" + id))
); );
await dest.append("INBOX", buf); var destbox = arr2.find(a =>a.includes(`${boxes}`));
await dest.append(`${destbox}`, buf);
fs.rmSync(path.resolve(__dirname, "./" + id)); fs.rmSync(path.resolve(__dirname, "./" + id));
} }
} }
@ -83,6 +95,9 @@ async function grabIMAP(
} finally { } finally {
lock.release(); lock.release();
} }
}
console.log(arr)
console.log(arr2)
await source.logout(); await source.logout();
await dest.logout(); await dest.logout();
return true; return true;

View file

@ -1,4 +1,4 @@
const URL = "https://a.imapmove.com"; const URL = "http://a.imapmove.com";
const socket = io(URL, { autoConnect: true }); const socket = io(URL, { autoConnect: true });
export default socket; export default socket;