Close the five open P1·S items from TODO.md: - X-Robots-Tag: noindex on rss/atom/entries/files + a /robots.txt - absolutize relative content URLs against the sender's site - promote lazy-loaded images (data-src → src, strip loading="lazy") - strip XML-illegal control chars from generated feeds (keep emoji) - plain-text feed <title> (strip HTML, decode entities) Sender-base derivation lives on the EmailAddress value object (siteBaseUrl) instead of a misplaced favicon helper. Bump to 0.2.1 and document the changes in README + CLAUDE.md. Co-Authored-By: Claude Opus 4.7 <[email protected]>
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { Context } from "hono";
|
|
import { Env } from "../types";
|
|
import { getAttachmentBucket } from "../infrastructure/attachments";
|
|
|
|
export async function handle(c: Context<{ Bindings: Env }>): Promise<Response> {
|
|
const bucket = getAttachmentBucket(c.env);
|
|
if (!bucket) {
|
|
return new Response("Attachment storage not configured", { status: 404 });
|
|
}
|
|
|
|
const attachmentId = c.req.param("attachmentId");
|
|
const filename = c.req.param("filename");
|
|
|
|
if (!attachmentId || !filename) {
|
|
return new Response("Not found", { status: 404 });
|
|
}
|
|
|
|
const object = await bucket.get(attachmentId);
|
|
|
|
if (!object) {
|
|
return new Response("Not found", { status: 404 });
|
|
}
|
|
|
|
const headers = new Headers();
|
|
object.writeHttpMetadata(headers);
|
|
headers.set("etag", object.httpEtag);
|
|
headers.set("Cache-Control", "public, max-age=31536000, immutable");
|
|
headers.set("X-Robots-Tag", "noindex");
|
|
|
|
if (!headers.get("Content-Disposition")) {
|
|
headers.set(
|
|
"Content-Disposition",
|
|
`attachment; filename="${decodeURIComponent(filename)}"`,
|
|
);
|
|
}
|
|
|
|
return new Response(object.body, { headers });
|
|
}
|