diff --git a/.gitignore b/.gitignore
index 14e4361..f80343d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
/node_modules
/static/feeds/*
!/static/feeds/.gitkeep
+/static/alternate/*
+!/static/alternate/.gitkeep
diff --git a/index.ts b/index.ts
index e47a370..83a9755 100644
--- a/index.ts
+++ b/index.ts
@@ -34,6 +34,7 @@ export const webServer = express()
try {
const { name } = req.body;
const identifier = createIdentifier();
+ await writeFileAtomic(alternatePath(identifier), created(identifier));
await writeFileAtomic(feedPath(identifier), feed(X(name), identifier));
res.send(
layout(`
@@ -61,10 +62,15 @@ export const emailServer = new SMTPServer({
async onData(stream, session, callback) {
try {
const email = await mailparser.simpleParser(stream);
+ const identifier = createIdentifier();
+ const content =
+ typeof email.html === "string" ? email.html : email.textAsHtml ?? "";
+ await writeFileAtomic(alternatePath(identifier), content);
const newEntry = entry(
X(email.subject ?? ""),
X(email.from?.text ?? ""),
- X(typeof email.html === "string" ? email.html : email.textAsHtml ?? "")
+ X(content),
+ identifier
);
for (const { address } of session.envelope.rcptTo) {
const match = address.match(
@@ -154,7 +160,9 @@ function feed(name: string, identifier: string): string {
-
+