Commit 3567282e authored by roadscape's avatar roadscape

fix docker build

parent 98f64bea
......@@ -3,9 +3,9 @@
import * as config from 'config'
import { base58Enc } from './utils'
import { Account } from 'dsteem'
import {KoaContext, rpcClient} from './common'
import {APIError} from './error'
import { Account } from 'dsteem'
const DefaultAvatar = config.get('default_avatar') as string
const AvatarSizes: {[size: string]: number} = {
......@@ -23,21 +23,23 @@ export async function avatarHandler(ctx: KoaContext) {
const username = ctx.params['username']
const size = AvatarSizes[ctx.params['size']] || AvatarSizes.medium
interface IExtendedAccount extends Account {
posting_json_metadata?: string;
interface ExtendedAccount extends Account {
posting_json_metadata?: string
}
const [account]: IExtendedAccount[] = await rpcClient.database.getAccounts([username])
const [account]: ExtendedAccount[] = await rpcClient.database.getAccounts([username])
APIError.assert(account, APIError.Code.NoSuchAccount)
let metadata;
let metadata
// read from `posting_json_metadata` if version flag is set
if(account.posting_json_metadata) {
if (account.posting_json_metadata) {
try {
metadata = JSON.parse(account.posting_json_metadata)
if(!metadata.profile || !metadata.profile.version) metadata = {}
if (!metadata.profile || !metadata.profile.version) {
metadata = {}
}
} catch (error) {
ctx.log.debug(error, 'unable to parse json_metadata for %s', account.name)
metadata = {}
......@@ -45,7 +47,7 @@ export async function avatarHandler(ctx: KoaContext) {
}
// otherwise, fall back to reading from `json_metadata`
if(!metadata) {
if (!metadata) {
try {
metadata = JSON.parse(account.json_metadata)
} catch (error) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment