Basic data enrichment (#3023)
* Add Enrich to frontend * Naive backend implementation * Add work email check * Rename Enrich to Quick Action * Refactor logic to a separate service * Refacto to separate IntelligenceService * Small fixes * Missing Break statement * Address PR comments * Create company interface * Improve edge case handling * Use httpService instead of Axios * Fix server tests
This commit is contained in:
16348
packages/twenty-server/src/utils/email-providers.ts
Normal file
16348
packages/twenty-server/src/utils/email-providers.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
import axios from 'axios';
|
||||
import { Axios } from 'axios';
|
||||
|
||||
const cropRegex = /([w|h])([0-9]+)/;
|
||||
|
||||
@ -22,8 +22,11 @@ export const getCropSize = (value: ShortCropSize): CropSize | null => {
|
||||
};
|
||||
};
|
||||
|
||||
export const getImageBufferFromUrl = async (url: string): Promise<Buffer> => {
|
||||
const response = await axios.get(url, {
|
||||
export const getImageBufferFromUrl = async (
|
||||
url: string,
|
||||
axiosInstance: Axios,
|
||||
): Promise<Buffer> => {
|
||||
const response = await axiosInstance.get(url, {
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
|
||||
|
||||
21
packages/twenty-server/src/utils/is-work-email.ts
Normal file
21
packages/twenty-server/src/utils/is-work-email.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { emailProvidersSet } from 'src/utils/email-providers';
|
||||
|
||||
export const isWorkEmail = (email: string) => {
|
||||
if (!email) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const fields = email.split('@');
|
||||
|
||||
if (fields.length !== 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const domain = fields[1];
|
||||
|
||||
if (!domain) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !emailProvidersSet.has(domain);
|
||||
};
|
||||
Reference in New Issue
Block a user