fixing a microsoft graph api error (#12154)
The issue is "Microsoft Graph API unknown error: TypeError: Cannot read properties of undefined (reading 'emailAddress')" Sentry : https://twenty-v7.sentry.io/issues/6605750776/events/7feb4f5949a64ab78bb429cffb7f0fea/?project=4507072499810304 Fixes https://github.com/twentyhq/core-team-issues/issues/981
This commit is contained in:
@ -3,6 +3,7 @@ import { Injectable, Logger } from '@nestjs/common';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity';
|
||||
import { MessageDirection } from 'src/modules/messaging/common/enums/message-direction.enum';
|
||||
import { computeMessageDirection } from 'src/modules/messaging/message-import-manager/drivers/gmail/utils/compute-message-direction.util';
|
||||
import { MicrosoftImportDriverException } from 'src/modules/messaging/message-import-manager/drivers/microsoft/exceptions/microsoft-import-driver.exception';
|
||||
import { MicrosoftGraphBatchResponse } from 'src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-get-messages.interface';
|
||||
@ -83,18 +84,24 @@ export class MicrosoftGetMessagesService {
|
||||
'from',
|
||||
),
|
||||
...formatAddressObjectAsParticipants(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
response?.toRecipients?.map((recipient) => recipient.emailAddress),
|
||||
response?.toRecipients
|
||||
?.filter(isDefined)
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
.map((recipient) => recipient.emailAddress),
|
||||
'to',
|
||||
),
|
||||
...formatAddressObjectAsParticipants(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
response?.ccRecipients?.map((recipient) => recipient.emailAddress),
|
||||
response?.ccRecipients
|
||||
?.filter(isDefined)
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
.map((recipient) => recipient.emailAddress),
|
||||
'cc',
|
||||
),
|
||||
...formatAddressObjectAsParticipants(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
response?.bccRecipients?.map((recipient) => recipient.emailAddress),
|
||||
response?.bccRecipients
|
||||
?.filter(isDefined)
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
.map((recipient) => recipient.emailAddress),
|
||||
'bcc',
|
||||
),
|
||||
];
|
||||
@ -111,10 +118,12 @@ export class MicrosoftGetMessagesService {
|
||||
response.body?.contentType === 'text' ? response.body?.content : '',
|
||||
headerMessageId: response.internetMessageId,
|
||||
messageThreadExternalId: response.conversationId,
|
||||
direction: computeMessageDirection(
|
||||
response.from.emailAddress.address,
|
||||
connectedAccount,
|
||||
),
|
||||
direction: response.from
|
||||
? computeMessageDirection(
|
||||
response.from.emailAddress.address,
|
||||
connectedAccount,
|
||||
)
|
||||
: MessageDirection.INCOMING,
|
||||
participants: safeParticipantsFormat,
|
||||
attachments: [],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user