run server as typescript
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Imap, { ImapMessageAttributes, MailBoxes } from "imap";
|
||||
import { getMailbox, updateMailbox } from "../../db/imap/imap";
|
||||
import { Attrs } from "../../interfaces/mail/attrs.interface";
|
||||
import { Attrs, AttrsWithEnvelope } from "../../interfaces/mail/attrs.interface";
|
||||
import logger from "../../system/Logger";
|
||||
import RegisterMessageInApp from "../saveMessage";
|
||||
import { saveMessage } from "../storeMessage";
|
||||
@@ -31,7 +31,7 @@ export default class Box {
|
||||
|
||||
sync(savedUid, currentUid) {
|
||||
const promises: Promise<unknown>[] = [];
|
||||
const mails: ImapMessageAttributes[] = [];
|
||||
const mails: Attrs[] = [];
|
||||
logger.log(`Syncing from ${savedUid} to ${currentUid} uid`);
|
||||
const f = this.imap.seq.fetch(`${savedUid}:${currentUid}`, {
|
||||
// const f = this.imap.seq.fetch(`${savedUid}:${currentUid}`, {
|
||||
@@ -40,7 +40,7 @@ export default class Box {
|
||||
});
|
||||
|
||||
f.on("message", (msg, seqno) => {
|
||||
msg.once("attributes", (attrs: Attrs) => {
|
||||
msg.once("attributes", (attrs: AttrsWithEnvelope) => {
|
||||
console.log(attrs.envelope)
|
||||
mails.push(attrs);
|
||||
promises.push(saveMessage(attrs, this.id, this.imap));
|
||||
@@ -58,7 +58,7 @@ export default class Box {
|
||||
for (let j = i; j < (i + step && promises.length); j++) {
|
||||
await new Promise((resolve, reject) => {
|
||||
promises[j]
|
||||
.then(async (res) => {
|
||||
.then(async (res: number) => {
|
||||
const register = new RegisterMessageInApp(res, mails[j], this.id);
|
||||
await register.save();
|
||||
resolve("");
|
||||
|
||||
Reference in New Issue
Block a user