Skip to content

The open alternative to Salesforce, designed for AI.

4501 improve filters for emails imports (#4966)

bosiraphael764a3ebfde8b
diff --git a/packages/twenty-server/src/modules/messaging/utils/gmail-search-filter.util.ts b/packages/twenty-server/src/modules/messaging/utils/gmail-search-filter.util.ts
index cbfe5d522d0..38b12ca3357 100644
--- a/packages/twenty-server/src/modules/messaging/utils/gmail-search-filter.util.ts
+++ b/packages/twenty-server/src/modules/messaging/utils/gmail-search-filter.util.ts
@@ -1,14 +1,14 @@
export const gmailSearchFilterNonPersonalEmails =
- 'noreply|no-reply|do_not_reply|no.reply|accounts@|info@|admin@|contact@|hello@|support@|sales@|feedback@|service@|help@|mailer-daemon|notifications|digest|auto|apps|assign|comments|customer-success|enterprise|esign|express|forum|gc@|learn|mailer|marketing|messages|news|notification|payments|receipts|recrutement|security|service|support|team';
+ '*noreply@|*no-reply@|*do_not_reply@|*no.reply@|*info@|*contact@|*hello@|*support@|*feedback@|*service@|*help@';
export const gmailSearchFilterExcludeEmails = (emails: string[]): string => {
if (emails.length === 0) {
- return `from:-(${gmailSearchFilterNonPersonalEmails}`;
+ return `from:-(${gmailSearchFilterNonPersonalEmails} -category:promotions -category:social -category:forums`;
}
return `(in:inbox from:-(${gmailSearchFilterNonPersonalEmails}|${emails.join(
'|',
)})|(in:sent to:-(${gmailSearchFilterNonPersonalEmails}|${emails.join(
'|',
- )}))`;
+ )})) -category:promotions -category:social -category:forums`;
};
diff --git a/packages/twenty-server/src/modules/messaging/utils/is-person-email.util.ts b/packages/twenty-server/src/modules/messaging/utils/is-person-email.util.ts
deleted file mode 100644
index 387a94e5040..00000000000
--- a/packages/twenty-server/src/modules/messaging/utils/is-person-email.util.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export const isPersonEmail = (email: string | undefined): boolean => {
- if (!email) return false;
-
- const nonPersonalPattern =
- /noreply|no-reply|do_not_reply|no\.reply|^(accounts@|info@|admin@|contact@|hello@|support@|sales@|feedback@|service@|help@|mailer-daemon|notifications?|digest|auto|apps|assign|comments|customer-success|enterprise|esign|express|forum|gc@|learn|mailer|marketing|messages|news|notification|payments|receipts|recrutement|security|service|support|team)/;
-
- return !nonPersonalPattern.test(email);
-};