Fondation

This commit is contained in:
alma 2026-01-16 22:48:55 +01:00
parent d2926c452a
commit 04de49aad5
2 changed files with 14 additions and 21 deletions

View File

@ -955,9 +955,9 @@ export async function getEmails(
if (graphCheck.useGraph && graphCheck.mailCredentialId) { if (graphCheck.useGraph && graphCheck.mailCredentialId) {
// Use Microsoft Graph API // Use Microsoft Graph API
logger.debug('[EMAIL] Using Microsoft Graph API', { logger.debug('[EMAIL] Using Microsoft Graph API', {
userId, userIdHash: Buffer.from(userId).toString('base64').slice(0, 12),
folder, folder,
mailCredentialId: graphCheck.mailCredentialId, mailCredentialIdHash: graphCheck.mailCredentialId ? Buffer.from(graphCheck.mailCredentialId).toString('base64').slice(0, 12) : null,
}); });
try { try {
@ -1141,7 +1141,7 @@ export async function getEmails(
const end = Math.max(1, totalEmails - ((page - 1) * perPage)); const end = Math.max(1, totalEmails - ((page - 1) * perPage));
logger.debug('[EMAIL] Fetching messages range', { logger.debug('[EMAIL] Fetching messages range', {
folder, folder,
accountId: resolvedAccountId, accountIdHash: Buffer.from(resolvedAccountId).toString('base64').slice(0, 12),
start, start,
end, end,
}); });
@ -1763,8 +1763,8 @@ export async function sendEmail(
if (graphCheck.useGraph && graphCheck.mailCredentialId) { if (graphCheck.useGraph && graphCheck.mailCredentialId) {
// Use Microsoft Graph API to send email // Use Microsoft Graph API to send email
logger.debug('[EMAIL] Sending email via Microsoft Graph API', { logger.debug('[EMAIL] Sending email via Microsoft Graph API', {
userId, userIdHash: Buffer.from(userId).toString('base64').slice(0, 12),
mailCredentialId: graphCheck.mailCredentialId, mailCredentialIdHash: graphCheck.mailCredentialId ? Buffer.from(graphCheck.mailCredentialId).toString('base64').slice(0, 12) : null,
}); });
try { try {
@ -1788,7 +1788,7 @@ export async function sendEmail(
}; };
} catch (error) { } catch (error) {
logger.error('[EMAIL] Error sending email via Graph API', { logger.error('[EMAIL] Error sending email via Graph API', {
userId, userIdHash: Buffer.from(userId).toString('base64').slice(0, 12),
error: error instanceof Error ? error.message : String(error), error: error instanceof Error ? error.message : String(error),
}); });
return { return {

View File

@ -143,19 +143,16 @@ export async function fetchGraphEmails(
url += `?${params.toString()}`; url += `?${params.toString()}`;
logger.debug('Fetching emails from Microsoft Graph API', { logger.debug('Fetching emails from Microsoft Graph API', {
mailCredentialId, mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
folderId,
top, top,
skip, skip,
skipToken: skipToken ? 'present' : 'none', skipToken: skipToken ? 'present' : 'none',
url,
}); });
const response = await client.get(url); const response = await client.get(url);
logger.debug('Microsoft Graph API response', { logger.debug('Microsoft Graph API response', {
mailCredentialId, mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
folderId,
emailCount: response.data?.value?.length || 0, emailCount: response.data?.value?.length || 0,
hasNextLink: !!response.data?.['@odata.nextLink'], hasNextLink: !!response.data?.['@odata.nextLink'],
}); });
@ -163,8 +160,7 @@ export async function fetchGraphEmails(
return response.data; return response.data;
} catch (error: any) { } catch (error: any) {
logger.error('Error fetching emails from Microsoft Graph', { logger.error('Error fetching emails from Microsoft Graph', {
mailCredentialId, mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
folderId,
error: error instanceof Error ? error.message : String(error), error: error instanceof Error ? error.message : String(error),
status: error.response?.status, status: error.response?.status,
statusText: error.response?.statusText, statusText: error.response?.statusText,
@ -198,8 +194,7 @@ export async function fetchGraphEmail(
return response.data; return response.data;
} catch (error: any) { } catch (error: any) {
logger.error('Error fetching email from Microsoft Graph', { logger.error('Error fetching email from Microsoft Graph', {
mailCredentialId, mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
messageId,
error: error instanceof Error ? error.message : String(error), error: error instanceof Error ? error.message : String(error),
}); });
@ -230,7 +225,7 @@ export async function fetchGraphMailFolders(
return response.data.value || []; return response.data.value || [];
} catch (error: any) { } catch (error: any) {
logger.error('Error fetching mail folders from Microsoft Graph', { logger.error('Error fetching mail folders from Microsoft Graph', {
mailCredentialId, mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
error: error instanceof Error ? error.message : String(error), error: error instanceof Error ? error.message : String(error),
}); });
@ -317,7 +312,7 @@ export async function sendGraphEmail(
return { id: draftId }; return { id: draftId };
} catch (error: any) { } catch (error: any) {
logger.error('Error sending email via Microsoft Graph', { logger.error('Error sending email via Microsoft Graph', {
mailCredentialId, mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
error: error instanceof Error ? error.message : String(error), error: error instanceof Error ? error.message : String(error),
status: error.response?.status, status: error.response?.status,
statusText: error.response?.statusText, statusText: error.response?.statusText,
@ -347,8 +342,7 @@ export async function markGraphEmailAsRead(
}); });
} catch (error: any) { } catch (error: any) {
logger.error('Error marking email as read via Microsoft Graph', { logger.error('Error marking email as read via Microsoft Graph', {
mailCredentialId, mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
messageId,
isRead, isRead,
error: error instanceof Error ? error.message : String(error), error: error instanceof Error ? error.message : String(error),
}); });
@ -376,8 +370,7 @@ export async function getGraphUnreadCount(
return response.data.unreadItemCount || 0; return response.data.unreadItemCount || 0;
} catch (error: any) { } catch (error: any) {
logger.error('Error getting unread count from Microsoft Graph', { logger.error('Error getting unread count from Microsoft Graph', {
mailCredentialId, mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
folderId,
error: error instanceof Error ? error.message : String(error), error: error instanceof Error ? error.message : String(error),
}); });