add inital msg init
This commit is contained in:
parent
d87730a09b
commit
6c4815beb1
31
server.js
31
server.js
@ -4,7 +4,7 @@ const { EventEmitter } = require("events");
|
|||||||
|
|
||||||
const initalConfig = `{
|
const initalConfig = `{
|
||||||
"pop3-config": {
|
"pop3-config": {
|
||||||
"user": "example@example.com",
|
"user": "example",
|
||||||
"password": "example",
|
"password": "example",
|
||||||
"host": "pop3.example.com"
|
"host": "pop3.example.com"
|
||||||
}
|
}
|
||||||
@ -27,11 +27,30 @@ class POP3 extends EventEmitter {
|
|||||||
super();
|
super();
|
||||||
this.pop3cmd = new Pop3Command(global.config["pop3-config"]);
|
this.pop3cmd = new Pop3Command(global.config["pop3-config"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async init () {
|
||||||
|
const msg = (
|
||||||
|
await pop3.pop3cmd.UIDL()
|
||||||
|
).map(async x => {
|
||||||
|
x[1] = {
|
||||||
|
uid: x[1],
|
||||||
|
msg: await await pop3.pop3cmd.RETR(+x[0])
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
});
|
||||||
|
this.msg = Object.fromEntries(
|
||||||
|
await Promise.all(msg)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pop3 = new POP3();
|
const pop3 = new POP3();
|
||||||
|
pop3.init().then(() => {
|
||||||
let interval = setTimeout(async () => {
|
let interval = setTimeout(async () => {
|
||||||
const list = await pop3.pop3cmd.UIDL();
|
console.log(pop3.msg);
|
||||||
console.dir(list);
|
//const list = await pop3.pop3cmd.UIDL();
|
||||||
}, 1);
|
//console.log(list);
|
||||||
|
//const str = await pop3.pop3cmd.RETR(1);
|
||||||
|
//console.log(str);
|
||||||
|
}, 1);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user