Public
Back
Version 1
11/3/2022
export let hnEmail = async ({ posts, username }) => {
let authors = Array.from(new Set(posts.map((p) => p.author))).slice(0, 3);
let subject = `[HN Follow] New from ${authors.join(", ")}`;
let postsText = await Promise.all(posts.map(stevekrouse.hnResultToText));
let unsubscribeURL = `api.val.town/eval/@${username}.hnClear?id=${@me.hnFollowInterval}`;
let info = `\n\n\nEmail by hnfollow.com & https://val.town`;
let unsubscribe = `Click here to unsubscribe: https://${unsubscribeURL}`;
let text = [postsText.join("\n\n"), info, unsubscribe].join("\n\n");
return { text, subject };
};
Updated: October 23, 2023