mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-23 22:12:24 +03:00
3571 remove reply quotations from emails (#3630)
* lib is working * update * plural
This commit is contained in:
parent
377fd23c90
commit
b0c14ba5b9
@ -92,6 +92,7 @@
|
||||
"passport-local": "^1.0.0",
|
||||
"pg": "^8.11.3",
|
||||
"pg-boss": "^9.0.3",
|
||||
"planer": "^1.2.0",
|
||||
"react": "^18.2.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"sharp": "^0.32.1",
|
||||
|
@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
||||
import { simpleParser, AddressObject } from 'mailparser';
|
||||
import planer from 'planer';
|
||||
|
||||
import {
|
||||
GmailMessage,
|
||||
@ -197,6 +198,21 @@ export class FetchMessagesByBatchesService {
|
||||
...this.formatAddressObjectAsParticipants(bcc, 'bcc'),
|
||||
];
|
||||
|
||||
let textWithoutReplyQuotations = text;
|
||||
|
||||
if (text)
|
||||
try {
|
||||
textWithoutReplyQuotations = planer.extractFrom(
|
||||
text,
|
||||
'text/plain',
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(
|
||||
'Error while trying to remove reply quotations',
|
||||
error,
|
||||
);
|
||||
}
|
||||
|
||||
const messageFromGmail: GmailMessage = {
|
||||
historyId,
|
||||
externalId: id,
|
||||
@ -207,7 +223,7 @@ export class FetchMessagesByBatchesService {
|
||||
fromHandle: from.value[0].address || '',
|
||||
fromDisplayName: from.value[0].name || '',
|
||||
participants,
|
||||
text: text || '',
|
||||
text: textWithoutReplyQuotations || '',
|
||||
html: html || '',
|
||||
attachments,
|
||||
};
|
||||
|
@ -36032,6 +36032,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"planer@npm:^1.2.0":
|
||||
version: 1.2.0
|
||||
resolution: "planer@npm:1.2.0"
|
||||
checksum: d2515294e772bbba1b26c0fa611590369f1ff510b11855eb55cb30e093286c888868020b9a62e41a46a4c5686def03f5c34fd91801fc9104404ffeb01ad46b78
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"playwright-core@npm:1.40.1, playwright-core@npm:>=1.2.0":
|
||||
version: 1.40.1
|
||||
resolution: "playwright-core@npm:1.40.1"
|
||||
@ -42451,6 +42458,7 @@ __metadata:
|
||||
passport-local: "npm:^1.0.0"
|
||||
pg: "npm:^8.11.3"
|
||||
pg-boss: "npm:^9.0.3"
|
||||
planer: "npm:^1.2.0"
|
||||
react: "npm:^18.2.0"
|
||||
rimraf: "npm:^3.0.2"
|
||||
sharp: "npm:^0.32.1"
|
||||
|
Loading…
Reference in New Issue
Block a user