From 1e698ae2893e56872afe5788082f9e10715eca30 Mon Sep 17 00:00:00 2001 From: Niko Date: Sun, 6 Mar 2022 20:37:27 +0100 Subject: [PATCH] Add default avatar in accounts.getAccount API --- api/src/api/accounts.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/src/api/accounts.js b/api/src/api/accounts.js index 51c2f22..be475c9 100644 --- a/api/src/api/accounts.js +++ b/api/src/api/accounts.js @@ -86,9 +86,13 @@ async function getAccount(id) { const person = await db.getAPObject(id, 'Person') const username = utils.firstIfArray(person.preferredUsername) const icon = utils.firstIfArray(person.icon) - const newicon = { - type: utils.firstIfArray(icon.mediaType), - url: utils.firstIfArray(icon.url), + var avatar = { type: 'image/png', + url: '/assets/images/default_profile.png' } + if (icon !== null) { + avatar = { + type: utils.firstIfArray(icon.mediaType), + url: utils.firstIfArray(icon.url), + } } var props = {} if (person.attachment !== undefined) { @@ -120,7 +124,7 @@ async function getAccount(id) { acct: username+'@'+(new URL(person.id)).hostname, name: utils.firstIfArray(person.name), summary: utils.firstIfArray(person.summary), - avatar: newicon, + avatar, username, props, }