fix types highestmodseq
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import Imap, { ImapMessageAttributes, Box } from "imap";
|
||||
import Imap, { Box } from "imap";
|
||||
import { getMailbox, getMailboxModseq, updateMailbox, updateMailboxModseq } from "../../db/imap/imap-db";
|
||||
import { Attrs, AttrsWithEnvelope } from "../../interfaces/mail/attrs.interface";
|
||||
import logger from "../../system/Logger";
|
||||
@@ -35,6 +35,7 @@ export default class Mailbox {
|
||||
this.box = (await getMailbox(this.id))[0];
|
||||
const isReadOnly = false;
|
||||
this.imap.openBox(this.boxName, isReadOnly, (err, box) => {
|
||||
console.log(typeof(box.highestmodseq))
|
||||
if (err) logger.err(err);
|
||||
|
||||
// sync messages and flags
|
||||
@@ -62,7 +63,7 @@ export default class Mailbox {
|
||||
|
||||
async updateModseq(newModseq: number) {
|
||||
updateMailboxModseq(this.id, newModseq).then(() => {
|
||||
this.box.highestmodseq = newModseq;
|
||||
this.box.highestmodseq = newModseq.toString();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ export default class Mailbox {
|
||||
|
||||
// sync flags
|
||||
const lastModseq = (await getMailboxModseq(this.id))[0]?.modseq ?? 0;
|
||||
if (box.highestmodseq > lastModseq) {
|
||||
if (parseInt(box.highestmodseq) > lastModseq) {
|
||||
const fetchStream = this.imap.fetch("1:*", { bodies: "", modifiers: { changedsince: lastModseq } });
|
||||
fetchStream.on("message", (message) => {
|
||||
message.once("attributes", (attrs) => {
|
||||
@@ -93,7 +94,7 @@ export default class Mailbox {
|
||||
} else {
|
||||
logger.log("Flags already up to date")
|
||||
}
|
||||
this.updateModseq(box.highestmodseq);
|
||||
this.updateModseq(parseInt(box.highestmodseq));
|
||||
}
|
||||
|
||||
async syncMail(savedUid: number, currentUid: number) {
|
||||
|
||||
Reference in New Issue
Block a user