Fondation
This commit is contained in:
parent
d2926c452a
commit
04de49aad5
@ -955,9 +955,9 @@ export async function getEmails(
|
||||
if (graphCheck.useGraph && graphCheck.mailCredentialId) {
|
||||
// Use Microsoft Graph API
|
||||
logger.debug('[EMAIL] Using Microsoft Graph API', {
|
||||
userId,
|
||||
userIdHash: Buffer.from(userId).toString('base64').slice(0, 12),
|
||||
folder,
|
||||
mailCredentialId: graphCheck.mailCredentialId,
|
||||
mailCredentialIdHash: graphCheck.mailCredentialId ? Buffer.from(graphCheck.mailCredentialId).toString('base64').slice(0, 12) : null,
|
||||
});
|
||||
|
||||
try {
|
||||
@ -1141,7 +1141,7 @@ export async function getEmails(
|
||||
const end = Math.max(1, totalEmails - ((page - 1) * perPage));
|
||||
logger.debug('[EMAIL] Fetching messages range', {
|
||||
folder,
|
||||
accountId: resolvedAccountId,
|
||||
accountIdHash: Buffer.from(resolvedAccountId).toString('base64').slice(0, 12),
|
||||
start,
|
||||
end,
|
||||
});
|
||||
@ -1763,8 +1763,8 @@ export async function sendEmail(
|
||||
if (graphCheck.useGraph && graphCheck.mailCredentialId) {
|
||||
// Use Microsoft Graph API to send email
|
||||
logger.debug('[EMAIL] Sending email via Microsoft Graph API', {
|
||||
userId,
|
||||
mailCredentialId: graphCheck.mailCredentialId,
|
||||
userIdHash: Buffer.from(userId).toString('base64').slice(0, 12),
|
||||
mailCredentialIdHash: graphCheck.mailCredentialId ? Buffer.from(graphCheck.mailCredentialId).toString('base64').slice(0, 12) : null,
|
||||
});
|
||||
|
||||
try {
|
||||
@ -1788,7 +1788,7 @@ export async function sendEmail(
|
||||
};
|
||||
} catch (error) {
|
||||
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),
|
||||
});
|
||||
return {
|
||||
|
||||
@ -143,19 +143,16 @@ export async function fetchGraphEmails(
|
||||
url += `?${params.toString()}`;
|
||||
|
||||
logger.debug('Fetching emails from Microsoft Graph API', {
|
||||
mailCredentialId,
|
||||
folderId,
|
||||
mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
|
||||
top,
|
||||
skip,
|
||||
skipToken: skipToken ? 'present' : 'none',
|
||||
url,
|
||||
});
|
||||
|
||||
const response = await client.get(url);
|
||||
|
||||
logger.debug('Microsoft Graph API response', {
|
||||
mailCredentialId,
|
||||
folderId,
|
||||
mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
|
||||
emailCount: response.data?.value?.length || 0,
|
||||
hasNextLink: !!response.data?.['@odata.nextLink'],
|
||||
});
|
||||
@ -163,8 +160,7 @@ export async function fetchGraphEmails(
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
logger.error('Error fetching emails from Microsoft Graph', {
|
||||
mailCredentialId,
|
||||
folderId,
|
||||
mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
status: error.response?.status,
|
||||
statusText: error.response?.statusText,
|
||||
@ -198,8 +194,7 @@ export async function fetchGraphEmail(
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
logger.error('Error fetching email from Microsoft Graph', {
|
||||
mailCredentialId,
|
||||
messageId,
|
||||
mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
|
||||
@ -230,7 +225,7 @@ export async function fetchGraphMailFolders(
|
||||
return response.data.value || [];
|
||||
} catch (error: any) {
|
||||
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),
|
||||
});
|
||||
|
||||
@ -317,7 +312,7 @@ export async function sendGraphEmail(
|
||||
return { id: draftId };
|
||||
} catch (error: any) {
|
||||
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),
|
||||
status: error.response?.status,
|
||||
statusText: error.response?.statusText,
|
||||
@ -347,8 +342,7 @@ export async function markGraphEmailAsRead(
|
||||
});
|
||||
} catch (error: any) {
|
||||
logger.error('Error marking email as read via Microsoft Graph', {
|
||||
mailCredentialId,
|
||||
messageId,
|
||||
mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
|
||||
isRead,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
@ -376,8 +370,7 @@ export async function getGraphUnreadCount(
|
||||
return response.data.unreadItemCount || 0;
|
||||
} catch (error: any) {
|
||||
logger.error('Error getting unread count from Microsoft Graph', {
|
||||
mailCredentialId,
|
||||
folderId,
|
||||
mailCredentialIdHash: Buffer.from(mailCredentialId).toString('base64').slice(0, 12),
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user