refactor: Move verbose email sync logs to debug level
Email sync operations now only show in LOG_LEVEL=debug mode. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,7 @@ export const syncEmailsFromSender = async (
|
|||||||
const { limit = 50, daysBack = 30 } = options;
|
const { limit = 50, daysBack = 30 } = options;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info(`Synchronizácia emailov s kontaktom: ${senderEmail} pre účet ${emailAccountId}`);
|
logger.debug(`Synchronizácia emailov s kontaktom: ${senderEmail}`);
|
||||||
|
|
||||||
const [contact] = await db
|
const [contact] = await db
|
||||||
.select({ companyId: contacts.companyId })
|
.select({ companyId: contacts.companyId })
|
||||||
@@ -37,14 +37,14 @@ export const syncEmailsFromSender = async (
|
|||||||
throw new Error('Priečinok Inbox nebol nájdený');
|
throw new Error('Priečinok Inbox nebol nájdený');
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Používam priečinky: Inbox (${inboxMailbox.id})${sentMailbox ? `, Sent (${sentMailbox.id})` : ''}`);
|
logger.debug(`Používam priečinky: Inbox, Sent`);
|
||||||
|
|
||||||
// Calculate date threshold (only emails from last X days)
|
// Calculate date threshold (only emails from last X days)
|
||||||
const dateThreshold = new Date();
|
const dateThreshold = new Date();
|
||||||
dateThreshold.setDate(dateThreshold.getDate() - daysBack);
|
dateThreshold.setDate(dateThreshold.getDate() - daysBack);
|
||||||
const dateThresholdISO = dateThreshold.toISOString();
|
const dateThresholdISO = dateThreshold.toISOString();
|
||||||
|
|
||||||
logger.info(`Filtrovanie: posledných ${daysBack} dní, z Inbox/Sent, pre ${senderEmail}`);
|
logger.debug(`Filtrovanie: posledných ${daysBack} dní pre ${senderEmail}`);
|
||||||
|
|
||||||
// Query emails FROM the contact
|
// Query emails FROM the contact
|
||||||
const queryFromResponse = await jmapRequest(jmapConfig, [
|
const queryFromResponse = await jmapRequest(jmapConfig, [
|
||||||
@@ -68,7 +68,7 @@ export const syncEmailsFromSender = async (
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const fromEmailIds = queryFromResponse.methodResponses[0][1].ids || [];
|
const fromEmailIds = queryFromResponse.methodResponses[0][1].ids || [];
|
||||||
logger.info(`Nájdených ${fromEmailIds.length} emailov OD ${senderEmail}`);
|
logger.debug(`Nájdených ${fromEmailIds.length} emailov OD ${senderEmail}`);
|
||||||
|
|
||||||
// Query emails TO the contact (from Sent folder if it exists)
|
// Query emails TO the contact (from Sent folder if it exists)
|
||||||
let toEmailIds = [];
|
let toEmailIds = [];
|
||||||
@@ -94,12 +94,12 @@ export const syncEmailsFromSender = async (
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
toEmailIds = queryToResponse.methodResponses[0][1].ids || [];
|
toEmailIds = queryToResponse.methodResponses[0][1].ids || [];
|
||||||
logger.info(`Nájdených ${toEmailIds.length} emailov PRE ${senderEmail}`);
|
logger.debug(`Nájdených ${toEmailIds.length} emailov PRE ${senderEmail}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Combine and deduplicate
|
// Combine and deduplicate
|
||||||
const emailIds = [...new Set([...fromEmailIds, ...toEmailIds])];
|
const emailIds = [...new Set([...fromEmailIds, ...toEmailIds])];
|
||||||
logger.info(`Celkovo unikátnych emailov: ${emailIds.length}`);
|
logger.debug(`Celkovo unikátnych emailov: ${emailIds.length}`);
|
||||||
|
|
||||||
if (emailIds.length === 0) {
|
if (emailIds.length === 0) {
|
||||||
return { total: 0, saved: 0 };
|
return { total: 0, saved: 0 };
|
||||||
@@ -200,7 +200,7 @@ export const syncEmailsFromSender = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.success(`Synchronizovaných ${savedCount} nových emailov s ${senderEmail}`);
|
logger.debug(`Synchronizovaných ${savedCount} nových emailov s ${senderEmail}`);
|
||||||
return { total: emailsList.length, saved: savedCount };
|
return { total: emailsList.length, saved: savedCount };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Nepodarilo sa synchronizovať emaily s kontaktom', error);
|
logger.error('Nepodarilo sa synchronizovať emaily s kontaktom', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user