Skip to content

Commit dd30c1f

Browse files
authored
fix: disable extracting name from signature (#2486)
1 parent 03452d9 commit dd30c1f

File tree

4 files changed

+25
-39
lines changed

4 files changed

+25
-39
lines changed

backend/src/services/signature/llm/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ export const SignaturePrompt = {
117117
description:
118118
'Must always be "Person" as per schema.org type definition'
119119
},
120-
name: {
121-
type: 'string',
122-
description:
123-
'Full name exactly as written in the signature, preserving original spelling and capitalization'
124-
},
120+
// name: {
121+
// type: 'string',
122+
// description:
123+
// 'Full name exactly as written in the signature, preserving original spelling and capitalization'
124+
// },
125125
jobTitle: {
126126
type: 'string',
127127
description: 'Job title or position, only if explicitly stated'
@@ -158,7 +158,7 @@ export const SignaturePrompt = {
158158
'Array of social profile URLs (e.g., LinkedIn, Twitter); add https:// prefix if missing'
159159
}
160160
},
161-
required: ['@type', 'name'],
161+
required: ['@type'], // , 'name'
162162
additionalProperties: false
163163
}
164164
}
@@ -274,7 +274,7 @@ export class SignatureLLM implements ExtractSignature {
274274
private cleanOutput(signature: string, person: PersonLD): PersonLD | null {
275275
return removeFalsePositives(
276276
{
277-
name: undefinedIfFalsy(parseString(person.name)),
277+
// name: undefinedIfFalsy(parseString(person.name)),
278278
jobTitle: undefinedIfFalsy(parseString(person.jobTitle)),
279279
worksFor: undefinedIfFalsy(parseString(person.worksFor)),
280280
address: undefinedIfEmpty(parseStringArray(person.address) ?? []),

backend/src/workers/email-signature/handler.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ export class EmailSignatureProcessor {
129129
body: string,
130130
messageDate: string
131131
): Promise<void> {
132-
const signature =
133-
this.extractSignature(body);
132+
const signature = this.extractSignature(body);
134133

135134
if (!signature || !isUsefulSignatureContent(signature)) {
136135
this.logging.info('No signature found; skipping cache', {
@@ -211,12 +210,15 @@ export class EmailSignatureProcessor {
211210
const originalMessage = CleanQuotedForwardedReplies(text);
212211
const parsed = new EmailReplyParser().read(originalMessage);
213212
const sigFrag = parsed.fragments.filter((f) => f.isSignature()).pop();
214-
return sigFrag?.getContent() ?? originalMessage.trim()
215-
.split('\n')
216-
.filter((l) => l.trim())
217-
.slice(-4)
218-
.join('\n');
219-
213+
return (
214+
sigFrag?.getContent() ??
215+
originalMessage
216+
.trim()
217+
.split('\n')
218+
.filter((l) => l.trim())
219+
.slice(-4)
220+
.join('\n')
221+
);
220222
} catch (err) {
221223
this.logging.error('Failed to parse email body for signature', err);
222224
return null;

backend/src/workers/email-signature/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function isUsefulSignatureContent(signature: string): boolean {
3737

3838
const words = text.split(/\s+/);
3939
const hasURL = /(https?:\/\/|www\.)\S+/i.test(text);
40-
const hasDigits = /\d{2,}(?:[\s.,:\/-]?\d+)*/.test(text);
40+
const hasDigits = /\d{2,}(?:[\s.,:/-]?\d+)*/.test(text);
4141
const hasSymbols = /[@+]/.test(text);
4242

4343
const wordsMinMax =

micro-services/emails-fetcher/src/services/imap/ImapEmailsFetcher.ts

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -630,37 +630,21 @@ export default class ImapEmailsFetcher {
630630
encoding
631631
);
632632

633-
// decodeQuotedPrintable(
634-
// msg.bodyParts?.get(partId)?.toString() ?? '',
635-
// 'utf-8'
636-
// );
637-
638-
// if (headers && text?.length) {
639-
// try {
640-
// const { text: parsedText } = await simpleParser(
641-
// Buffer.concat([headers, text as Uint8Array<ArrayBufferLike>]),
642-
// {
643-
// skipHtmlToText: true,
644-
// skipTextToHtml: true,
645-
// skipImageLinks: true,
646-
// skipTextLinks: true
647-
// }
648-
// );
649-
// text = parsedText?.slice(0, this.EMAIL_TEXT_MAX_LENGTH) || '';
650-
// } catch {
651-
// text = '';
652-
// }
653-
// }
654-
655633
if (text.length && from && date) {
634+
const { address, name } = from;
656635
await redisClient.xadd(
657636
this.signatureStream,
658637
'*',
659638
'message',
660639
JSON.stringify({
661640
type: 'email',
662641
data: {
663-
header: { from, messageId, messageDate: date, rawHeader: header },
642+
header: {
643+
from: { address: address?.toLowerCase(), name },
644+
messageId,
645+
messageDate: date,
646+
rawHeader: header
647+
},
664648
body: text,
665649
seqNumber: seq,
666650
folderPath,

0 commit comments

Comments
 (0)