Add IMAP flow logging configuration and enhance message arrival logging
This commit is contained in:
parent
b92ec64746
commit
30357418b5
@ -6,6 +6,7 @@ const i18n = require('./i18n');
|
||||
const NTFY_INTERNAL_URL = process.env.NTFY_URL || 'https://ntfy.sh';
|
||||
const CONFIG_PATH = process.env.CONFIG_PATH || './config.json';
|
||||
const LOG_LEVEL = process.env.LOG_LEVEL || 'info';
|
||||
const IMAP_FLOW_LOG = process.env.IMAP_FLOW_LOG || false;
|
||||
let config;
|
||||
|
||||
const fromIcon = "\uD83D\uDC64"; // 👤
|
||||
@ -87,12 +88,13 @@ async function watchAccount(acc) {
|
||||
user: acc.user,
|
||||
pass: acc.pass
|
||||
},
|
||||
logger: (LOG_LEVEL === 'debug' ? log.debug : false)
|
||||
logger: IMAP_FLOW_LOG ? log.debug : false
|
||||
});
|
||||
|
||||
const run = async () => {
|
||||
try {
|
||||
await client.connect();
|
||||
|
||||
let lock = await client.getMailboxLock('INBOX');
|
||||
log.info(`[${acc.name}] ${i18n.t('watch_started')}`);
|
||||
|
||||
@ -100,6 +102,8 @@ async function watchAccount(acc) {
|
||||
// Fetch only envelope data (Subject, From)
|
||||
let message = await client.fetchOne(data.count, { envelope: true });
|
||||
|
||||
log.debug(`[${acc.name}] New message arrived:`, message);
|
||||
|
||||
const subject = message.envelope.subject || i18n.t('no_subject');
|
||||
const fromInfo = message.envelope.from[0];
|
||||
const fromDisplay = fromInfo.name ? fromInfo.name : fromInfo.address;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user