This commit is contained in:
Leandro Facchinetti 2020-03-23 11:24:14 -04:00
parent 67662f21db
commit c5749d0b24
2 changed files with 16 additions and 6 deletions

View File

@ -45,12 +45,11 @@ export const emailServer = new SMTPServer({
(async () => {
const email = await mailparser.simpleParser(stream);
const { entry } = Entry({
title: email.subject,
author: email.from.text,
// FIXME: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43234 / typeof email.html !== "boolean" => email.html !== false
...(typeof email.html === "boolean"
? { html: false, content: email.text ?? "" }
: { content: email.html })
title: email.subject ?? "",
author: email.from?.text ?? "",
...(typeof email.html === "string"
? { content: email.html }
: { html: false, content: email.text ?? "" })
});
for (const { address } of session.envelope.rcptTo) {
const match = address.match(/^(\w+)@kill-the-newsletter.com$/);

View File

@ -80,6 +80,17 @@ describe("receive email", () => {
html: "<p>HTML content</p>"
});
});
test("missing from", async () => {
const identifier = await createFeed();
await emailClient.sendMail({
to: `${identifier}@kill-the-newsletter.com`,
subject: "New Message",
html: "<p>HTML content</p>"
});
const feed = await getFeed(identifier);
expect(feed).toMatch("HTML content");
});
});
afterAll(() => {