Skip to content

Commit

Permalink
Remove html from messages (#4229)
Browse files Browse the repository at this point in the history
* remove html

* remove html

* remove html from db
  • Loading branch information
bosiraphael authored Feb 29, 2024
1 parent f52a414 commit 8c08f1b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class MessageService {
const receivedAt = new Date(parseInt(message.internalDate));

await manager.query(
`INSERT INTO ${dataSourceMetadata.schema}."message" ("id", "headerMessageId", "subject", "receivedAt", "direction", "messageThreadId", "text", "html") VALUES ($1, $2, $3, $4, $5, $6, $7, $8)`,
`INSERT INTO ${dataSourceMetadata.schema}."message" ("id", "headerMessageId", "subject", "receivedAt", "direction", "messageThreadId", "text") VALUES ($1, $2, $3, $4, $5, $6, $7)`,
[
newMessageId,
message.headerMessageId,
Expand All @@ -221,7 +221,6 @@ export class MessageService {
messageDirection,
messageThreadId,
message.text,
message.html,
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,15 @@ export class FetchMessagesByBatchesService {
const body = atob(raw?.replace(/-/g, '+').replace(/_/g, '/'));

try {
const parsed = await simpleParser(body);

const {
subject,
messageId,
from,
to,
cc,
bcc,
text,
html,
attachments,
} = parsed;
const parsed = await simpleParser(body, {
skipHtmlToText: true,
skipImageLinks: true,
skipTextToHtml: true,
maxHtmlLengthToParse: 0,
});

const { subject, messageId, from, to, cc, bcc, text, attachments } =
parsed;

if (!from) throw new Error('From value is missing');

Expand Down Expand Up @@ -248,7 +244,6 @@ export class FetchMessagesByBatchesService {
fromDisplayName: from.value[0].name || '',
participants,
text: textWithoutReplyQuotations || '',
html: html || '',
attachments,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export type GmailMessage = {
fromDisplayName: string;
participants: Participant[];
text: string;
html: string;
attachments: Attachment[];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ export class MessageObjectMetadata extends BaseObjectMetadata {
})
text: string;

@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Html',
description: 'Html',
icon: 'IconMessage',
})
html: string;

@FieldMetadata({
type: FieldMetadataType.DATE_TIME,
label: 'Received At',
Expand Down

0 comments on commit 8c08f1b

Please sign in to comment.