diff --git a/.vscode/settings.json b/.vscode/settings.json index 3662b37..995e934 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "conventionalCommits.scopes": [ + "mastodon" + ] } \ No newline at end of file diff --git a/src/api/mastodon.ts b/src/api/mastodon.ts index 5771d45..ee4d3a8 100644 --- a/src/api/mastodon.ts +++ b/src/api/mastodon.ts @@ -1,4 +1,5 @@ import axios from 'axios'; +import { cache } from '../server'; async function findMastodonUser(username: string, host: string): Promise { const res = await axios.get(`${host}/api/v2/search?q=${username}`, { @@ -26,6 +27,11 @@ interface MastodonPost { } async function getLatestMastodonPost(id: string, host: string): Promise { + const cached = cache.get('mastodon') as MastodonPost | undefined; + if (cached != undefined) { + console.info('Returning mastodon from cache'); + return cached; + } const res = await axios.get( `${host}/api/v1/accounts/${id}/statuses?limit=1&exclude_reblogs=true`, { @@ -47,7 +53,7 @@ async function getLatestMastodonPost(id: string, host: string): Promise