run server as typescript

This commit is contained in:
grimhilt
2023-04-02 12:35:55 +02:00
parent a5d325818b
commit 7ba1ee083d
5 changed files with 9 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
import { getAddresseId } from "../db/mail";
import {simpleParser} from "mailparser";
import moment from "moment";
import Imap from "imap";
import {
registerMessage,
registerMailbox_message,
@@ -13,8 +14,9 @@ import {
import { getFieldId } from "../db/mail";
import logger from "../system/Logger";
import { AttrsWithEnvelope } from "../interfaces/mail/attrs.interface";
export function saveMessage(attrs, mailboxId, imap) {
export function saveMessage(attrs: AttrsWithEnvelope, mailboxId: number, imap: Imap): Promise<number> {
const envelope = attrs.envelope;
const ts = moment(new Date(envelope.date).getTime()).format("YYYY-MM-DD HH:mm:ss");
const rfc822size = attrs.size;
@@ -26,7 +28,7 @@ export function saveMessage(attrs, mailboxId, imap) {
const isSeen = attrs.flags.includes("\\Seen") ? 1 : 0; // todo verify
const deleted = attrs.flags.includes("\\Deleted") ? 1 : 0; // todo verify
registerMailbox_message(mailboxId, attrs.uid, messageId, attrs.modseq, isSeen, deleted);
registerMailbox_message(mailboxId, attrs.uid, messageId, attrs?.modseq, isSeen, deleted);
const f = imap.fetch(attrs.uid, { bodies: "" });
let buffer = "";