Skip to content

Commit 8cbb5a8

Browse files
committed
Add check to make sure the bot does not accept emails received before it started when Auto Read is disabled
1 parent c04ff8e commit 8cbb5a8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ const logger = require('tracer').colorConsole({ format: '[{{timestamp}} {{title}
55
const usernames = process.env.IMAP_USERNAMES.split(",");
66
const passwords = process.env.IMAP_PASSWORDS.split(",");
77
const githubURL = process.env.DISCORD_WH_URL;
8+
const imapMarkSeen = process.env.IMAP_MARK_SEEN === "false" ? false : true;
9+
10+
const startTime = new Date();
811

912
const triggerWebhook = (username, mail) => {
1013
logger.debug(mail)
1114
const description = mail.text === undefined ? "" : mail.text.substring(0, 1000);
1215

16+
if (!imapMarkSeen && mail.date < startTime) {
17+
return;
18+
}
19+
1320
require("axios").post(githubURL, {
1421
content: "",
1522
username: username,
@@ -42,7 +49,7 @@ usernames.forEach((username, index) => {
4249
port: process.env.IMAP_PORT || 143,
4350
tls: process.env.IMAP_TLS === "true" ? true : false,
4451
autotls: 'always',
45-
markSeen: process.env.IMAP_MARK_SEEN === "false" ? false : true
52+
markSeen: imapMarkSeen
4653
};
4754

4855
notifier(imap)

0 commit comments

Comments
 (0)