This commit is contained in:
parent
b53c5fbb40
commit
67662f21db
|
@ -48,7 +48,9 @@ export const emailServer = new SMTPServer({
|
|||
title: email.subject,
|
||||
author: email.from.text,
|
||||
// FIXME: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43234 / typeof email.html !== "boolean" => email.html !== false
|
||||
content: typeof email.html !== "boolean" ? email.html : email.textAsHtml
|
||||
...(typeof email.html === "boolean"
|
||||
? { html: false, content: email.text ?? "" }
|
||||
: { content: email.html })
|
||||
});
|
||||
for (const { address } of session.envelope.rcptTo) {
|
||||
const match = address.match(/^(\w+)@kill-the-newsletter.com$/);
|
||||
|
@ -219,11 +221,13 @@ function Feed({ name, identifier }: { name: string; identifier: string }) {
|
|||
function Entry({
|
||||
title,
|
||||
author,
|
||||
content
|
||||
content,
|
||||
html
|
||||
}: {
|
||||
title: string;
|
||||
author: string;
|
||||
content: string;
|
||||
html?: boolean;
|
||||
}) {
|
||||
return {
|
||||
entry: {
|
||||
|
@ -231,7 +235,10 @@ function Entry({
|
|||
title,
|
||||
author: { name: author },
|
||||
updated: now(),
|
||||
content: { $: { type: "html" }, _: content }
|
||||
content: {
|
||||
...(html === false ? {} : { $: { type: "html" } }),
|
||||
_: content
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
22
src/test.ts
22
src/test.ts
|
@ -36,6 +36,28 @@ describe("receive email", () => {
|
|||
expect(feed).toMatch("TEXT content");
|
||||
});
|
||||
|
||||
test("missing content", async () => {
|
||||
const identifier = await createFeed();
|
||||
await emailClient.sendMail({
|
||||
from: "publisher@example.com",
|
||||
to: `${identifier}@kill-the-newsletter.com`,
|
||||
subject: "New Message"
|
||||
});
|
||||
const feed = await getFeed(identifier);
|
||||
expect(feed).toMatch("New Message");
|
||||
});
|
||||
|
||||
test("missing subject", async () => {
|
||||
const identifier = await createFeed();
|
||||
await emailClient.sendMail({
|
||||
from: "publisher@example.com",
|
||||
to: `${identifier}@kill-the-newsletter.com`,
|
||||
html: "<p>HTML content</p>"
|
||||
});
|
||||
const feed = await getFeed(identifier);
|
||||
expect(feed).toMatch("HTML content");
|
||||
});
|
||||
|
||||
test("truncation", async () => {
|
||||
const identifier = await createFeed();
|
||||
for (const repetition of [...new Array(4).keys()])
|
||||
|
|
Loading…
Reference in New Issue