Use textAsHtml
This commit is contained in:
parent
169637d408
commit
50f9b473e0
|
@ -72,9 +72,8 @@ export const emailServer = new SMTPServer({
|
|||
const { entry } = Entry({
|
||||
title: email.subject ?? "",
|
||||
author: email.from?.text ?? "",
|
||||
...(typeof email.html === "string"
|
||||
? { content: email.html }
|
||||
: { html: false, content: email.text ?? "" })
|
||||
content:
|
||||
typeof email.html === "string" ? email.html : email.textAsHtml ?? ""
|
||||
});
|
||||
for (const { address } of session.envelope.rcptTo) {
|
||||
const match = address.match(/^(\w+)@kill-the-newsletter.com$/);
|
||||
|
@ -246,13 +245,11 @@ function Feed({ name, identifier }: { name: string; identifier: string }) {
|
|||
function Entry({
|
||||
title,
|
||||
author,
|
||||
content,
|
||||
html
|
||||
content
|
||||
}: {
|
||||
title: string;
|
||||
author: string;
|
||||
content: string;
|
||||
html?: boolean;
|
||||
}) {
|
||||
return {
|
||||
entry: {
|
||||
|
@ -267,10 +264,7 @@ function Entry({
|
|||
href: "https://www.kill-the-newsletter.com/entry"
|
||||
}
|
||||
},
|
||||
content: {
|
||||
...(html === false ? {} : { $: { type: "html" } }),
|
||||
_: content
|
||||
}
|
||||
content: { $: { type: "html" }, _: content }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
13
src/test.ts
13
src/test.ts
|
@ -36,6 +36,19 @@ describe("receive email", () => {
|
|||
expect(feed).toMatch("TEXT content");
|
||||
});
|
||||
|
||||
test("rich text content", async () => {
|
||||
const identifier = await createFeed();
|
||||
await emailClient.sendMail({
|
||||
from: "publisher@example.com",
|
||||
to: `${identifier}@kill-the-newsletter.com`,
|
||||
subject: "New Message",
|
||||
text: "TEXT content\n\nhttps://www.kill-the-newsletter.com\n\nMore text"
|
||||
});
|
||||
const feed = await getFeed(identifier);
|
||||
expect(feed).toMatch("TEXT content");
|
||||
expect(feed).toMatch(`href="https://www.kill-the-newsletter.com"`);
|
||||
});
|
||||
|
||||
test("missing content", async () => {
|
||||
const identifier = await createFeed();
|
||||
await emailClient.sendMail({
|
||||
|
|
Loading…
Reference in New Issue