Add default avatar in accounts.getAccount API

This commit is contained in:
Niko 2022-03-06 20:37:27 +01:00
parent 03356275e4
commit 1e698ae289
1 changed files with 8 additions and 4 deletions

View File

@ -86,10 +86,14 @@ 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 = {
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) {
await person.attachment.forEach((att) => {
@ -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,
}