diff --git a/functions/api/v1/accounts/[id]/followers.ts b/functions/api/v1/accounts/[id]/followers.ts index 8055b9c..21b4e6d 100644 --- a/functions/api/v1/accounts/[id]/followers.ts +++ b/functions/api/v1/accounts/[id]/followers.ts @@ -68,10 +68,14 @@ async function getLocalFollowers(request: Request, handle: Handle, db: Database) for (let i = 0, len = followers.length; i < len; i++) { const id = new URL(followers[i]) - const acct = urlToHandle(id) - const actor = await actors.get(id) - out.push(await loadExternalMastodonAccount(acct, actor)) + + try { + const actor = await actors.getAndCache(id, db) + out.push(await loadExternalMastodonAccount(acct, actor)) + } catch (err: any) { + console.warn(`failed to retrieve follower (${id}): ${err.message}`) + } } const headers = { diff --git a/functions/api/v1/accounts/[id]/following.ts b/functions/api/v1/accounts/[id]/following.ts index 040dcf4..8db6e49 100644 --- a/functions/api/v1/accounts/[id]/following.ts +++ b/functions/api/v1/accounts/[id]/following.ts @@ -68,10 +68,14 @@ async function getLocalFollowing(request: Request, handle: Handle, db: Database) for (let i = 0, len = following.length; i < len; i++) { const id = new URL(following[i]) - const acct = urlToHandle(id) - const actor = await actors.get(id) - out.push(await loadExternalMastodonAccount(acct, actor)) + + try { + const actor = await actors.getAndCache(id, db) + out.push(await loadExternalMastodonAccount(acct, actor)) + } catch (err: any) { + console.warn(`failed to retrieve following (${id}): ${err.message}`) + } } const headers = {