This commit is contained in:
parent
67662f21db
commit
c5749d0b24
|
@ -45,12 +45,11 @@ export const emailServer = new SMTPServer({
|
||||||
(async () => {
|
(async () => {
|
||||||
const email = await mailparser.simpleParser(stream);
|
const email = await mailparser.simpleParser(stream);
|
||||||
const { entry } = Entry({
|
const { entry } = Entry({
|
||||||
title: email.subject,
|
title: email.subject ?? "",
|
||||||
author: email.from.text,
|
author: email.from?.text ?? "",
|
||||||
// FIXME: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43234 / typeof email.html !== "boolean" => email.html !== false
|
...(typeof email.html === "string"
|
||||||
...(typeof email.html === "boolean"
|
? { content: email.html }
|
||||||
? { html: false, content: email.text ?? "" }
|
: { html: false, content: email.text ?? "" })
|
||||||
: { content: email.html })
|
|
||||||
});
|
});
|
||||||
for (const { address } of session.envelope.rcptTo) {
|
for (const { address } of session.envelope.rcptTo) {
|
||||||
const match = address.match(/^(\w+)@kill-the-newsletter.com$/);
|
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>"
|
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(() => {
|
afterAll(() => {
|
||||||
|
|
Loading…
Reference in New Issue