-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
37 lines (26 loc) · 870 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { getClient } from "@omnivoreClient";
import { sendEmail } from "@mailer";
if (import.meta.main) {
const { getArticles, archiveArticle, getUser, getArticle } = getClient();
const user = await getUser();
const username = user.me.profile.username;
const articles = await getArticles();
if (articles.search.edges.length === 0) {
Deno.exit(0);
}
const article = await getArticle({
username: username,
slug: articles.search.edges[0]?.node.slug,
includeFriendsHighlights: false,
});
const { content, title } = article.article.article;
const contentWithLink = `${content}\n\n
<a name="primo" href="${article.article.article.url}">Check the article.</a>
`;
await sendEmail({ content: contentWithLink, title });
await archiveArticle({
linkId: article.article.article.id,
archived: true,
});
}
Deno.exit(0);