Skip to content

The open alternative to Salesforce, designed for AI.

Microsoft mail sync: make sure that message list fetch is using max batch size (#11095)

Charles Bochetb49dc57bbf38
diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-get-message-list.service.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-get-message-list.service.ts
index 4d10286a09a..ba74f0e05b9 100644
--- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-get-message-list.service.ts
+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-get-message-list.service.ts
@@ -85,7 +85,11 @@ export class MicrosoftGetMessageListService {
return true;
};
- const pageIterator = new PageIterator(microsoftClient, response, callback);
+ const pageIterator = new PageIterator(microsoftClient, response, callback, {
+ headers: {
+ Prefer: `odata.maxpagesize=${MESSAGING_MICROSOFT_USERS_MESSAGES_LIST_MAX_RESULT}, IdType="ImmutableId"`,
+ },
+ });
await pageIterator.iterate().catch((error) => {
this.microsoftHandleErrorService.handleMicrosoftMessageFetchError(error);
@@ -203,7 +207,11 @@ export class MicrosoftGetMessageListService {
return true;
};
- const pageIterator = new PageIterator(microsoftClient, response, callback);
+ const pageIterator = new PageIterator(microsoftClient, response, callback, {
+ headers: {
+ Prefer: `odata.maxpagesize=${MESSAGING_MICROSOFT_USERS_MESSAGES_LIST_MAX_RESULT}, IdType="ImmutableId"`,
+ },
+ });
await pageIterator.iterate().catch((error) => {
this.microsoftHandleErrorService.handleMicrosoftMessageFetchError(error);