add smtpInstance in emailManager

This commit is contained in:
grimhilt
2023-04-09 23:46:33 +02:00
parent 160bb0c605
commit 4b21168547
5 changed files with 51 additions and 43 deletions

View File

@@ -1,4 +1,4 @@
import { Account } from "./ImapSync";
import { Account } from "../EmailManager";
import Imap from "imap";
import { getAllMailboxes, registerMailbox } from "../../db/imap/imap-db";

View File

@@ -1,33 +0,0 @@
import { getAllAccounts } from "../../db/imap/imap-db";
import logger from "../../system/Logger";
import { ImapInstance } from "./ImapInstance";
export interface Account {
id: number;
user: string
password?: string
}
export default class ImapSync {
instances: ImapInstance[]
constructor() {
this.instances = [];
}
init() {
getAllAccounts().then((accounts: Account[]) => {
for (let i = 0; i < accounts.length; i++) {
accounts[i].password = accounts[i]?.password?.toString().replace(/[\u{0080}-\u{FFFF}]/gu,"");
if (accounts[i].id == 2) continue; //debug_todo
this.addInstance(accounts[i]);
}
}).catch((err) => {
logger.err(err);
});
}
addInstance(config) {
this.instances.push(new ImapInstance(config));
}
}