started to convert to typescript
This commit is contained in:
33
back/mails/imap/ImapSync.ts
Normal file
33
back/mails/imap/ImapSync.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { getAllAccounts } from "../../db/imap/imap";
|
||||
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.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
addInstance(config) {
|
||||
this.instances.push(new ImapInstance(config));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user