This commit is contained in:
parent
67662f21db
commit
c5749d0b24
|
@ -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$/);
|
||||
|
|
11
src/test.ts
11
src/test.ts
|
@ -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(() => {
|
||||
|
|
Loading…
Reference in New Issue