3571 remove reply quotations from emails (#3630)
* lib is working * update * plural
This commit is contained in:
@ -92,6 +92,7 @@
|
|||||||
"passport-local": "^1.0.0",
|
"passport-local": "^1.0.0",
|
||||||
"pg": "^8.11.3",
|
"pg": "^8.11.3",
|
||||||
"pg-boss": "^9.0.3",
|
"pg-boss": "^9.0.3",
|
||||||
|
"planer": "^1.2.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"sharp": "^0.32.1",
|
"sharp": "^0.32.1",
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
|
|||||||
|
|
||||||
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
||||||
import { simpleParser, AddressObject } from 'mailparser';
|
import { simpleParser, AddressObject } from 'mailparser';
|
||||||
|
import planer from 'planer';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
GmailMessage,
|
GmailMessage,
|
||||||
@ -197,6 +198,21 @@ export class FetchMessagesByBatchesService {
|
|||||||
...this.formatAddressObjectAsParticipants(bcc, 'bcc'),
|
...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 = {
|
const messageFromGmail: GmailMessage = {
|
||||||
historyId,
|
historyId,
|
||||||
externalId: id,
|
externalId: id,
|
||||||
@ -207,7 +223,7 @@ export class FetchMessagesByBatchesService {
|
|||||||
fromHandle: from.value[0].address || '',
|
fromHandle: from.value[0].address || '',
|
||||||
fromDisplayName: from.value[0].name || '',
|
fromDisplayName: from.value[0].name || '',
|
||||||
participants,
|
participants,
|
||||||
text: text || '',
|
text: textWithoutReplyQuotations || '',
|
||||||
html: html || '',
|
html: html || '',
|
||||||
attachments,
|
attachments,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -36032,6 +36032,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
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":
|
"playwright-core@npm:1.40.1, playwright-core@npm:>=1.2.0":
|
||||||
version: 1.40.1
|
version: 1.40.1
|
||||||
resolution: "playwright-core@npm:1.40.1"
|
resolution: "playwright-core@npm:1.40.1"
|
||||||
@ -42451,6 +42458,7 @@ __metadata:
|
|||||||
passport-local: "npm:^1.0.0"
|
passport-local: "npm:^1.0.0"
|
||||||
pg: "npm:^8.11.3"
|
pg: "npm:^8.11.3"
|
||||||
pg-boss: "npm:^9.0.3"
|
pg-boss: "npm:^9.0.3"
|
||||||
|
planer: "npm:^1.2.0"
|
||||||
react: "npm:^18.2.0"
|
react: "npm:^18.2.0"
|
||||||
rimraf: "npm:^3.0.2"
|
rimraf: "npm:^3.0.2"
|
||||||
sharp: "npm:^0.32.1"
|
sharp: "npm:^0.32.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user