feat: saveEmail.js ,不在向 raw 字段插入数据
This commit is contained in:
parent
77030cc8fc
commit
ae870fb601
|
|
@ -20,7 +20,7 @@ async function saveEmail(stream) {
|
||||||
|
|
||||||
// Now, parse the buffered email content
|
// Now, parse the buffered email content
|
||||||
const parsed = await simpleParser(emailBuffer);
|
const parsed = await simpleParser(emailBuffer);
|
||||||
const rawEmail = emailBuffer.toString();
|
// const rawEmail = emailBuffer.toString(); // We are not saving the raw email content for now.
|
||||||
|
|
||||||
const recipient = parsed.to ? parsed.to.text : 'undisclosed-recipients';
|
const recipient = parsed.to ? parsed.to.text : 'undisclosed-recipients';
|
||||||
const sender = parsed.from ? parsed.from.text : 'unknown-sender';
|
const sender = parsed.from ? parsed.from.text : 'unknown-sender';
|
||||||
|
|
@ -33,8 +33,8 @@ async function saveEmail(stream) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const [result] = await db.execute(
|
const [result] = await db.execute(
|
||||||
'INSERT INTO emails (recipient, sender, subject, body, raw, received_at) VALUES (?, ?, ?, ?, ?, ?)',
|
'INSERT INTO emails (recipient, sender, subject, body, received_at) VALUES (?, ?, ?, ?, ?)',
|
||||||
[recipient, sender, subject, body, rawEmail, received_at]
|
[recipient, sender, subject, body, received_at]
|
||||||
);
|
);
|
||||||
const newEmailId = result.insertId;
|
const newEmailId = result.insertId;
|
||||||
|
|
||||||
|
|
@ -67,4 +67,4 @@ async function saveEmail(stream) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { saveEmail };
|
module.exports = { saveEmail };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue