28 lines
715 B
JavaScript
28 lines
715 B
JavaScript
const { getAllAccounts } = require("../../db/imap/imap");
|
|
const { DEBUG } = require("../../utils/debug");
|
|
const { ImapInstance } = require("./ImapInstance");
|
|
|
|
class ImapSync {
|
|
constructor() {
|
|
this.instances = [];
|
|
}
|
|
|
|
init() {
|
|
getAllAccounts().then((accounts) => {
|
|
for (let i = 0; i < accounts.length; i++) {
|
|
accounts[i].password = accounts[i]?.password.toString().replace(/[\u{0080}-\u{FFFF}]/gu,"");
|
|
this.addInstance(accounts[i]);
|
|
}
|
|
}).catch((err) => {
|
|
DEBUG.log(err);
|
|
});
|
|
}
|
|
|
|
addInstance(config) {
|
|
this.instances.push(new ImapInstance(config));
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
ImapSync
|
|
} |