import { email } from "https://esm.town/v/std/email?v=9";
import { sha256OfText } from "https://esm.town/v/jdan/sha256OfText";
export async function hashmail(e: {
from: string;
to: string[];
subject: string;
text: string;
html: string;
}) {
const trimmedText = e.text.trim();
const hash = await sha256OfText(trimmedText);
if (hash.startsWith("0000000")) {
return email({
text: `
You received a message from ${e.from}.
${e.subject}
${trimmedText}
which hashes to ${hash}
`,
subject: "Emailed received at @jdan.hashmail",
});
}
console.log(`
HASH FAILED!
You received a message from ${e.from}.
${e.subject}
${trimmedText}
JSON: ${JSON.stringify(trimmedText)}
which hashes to ${hash}
`);
}