Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
imagehoster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
imagehoster
Commits
fa808bf8
Commit
fa808bf8
authored
5 years ago
by
roadscape
Browse files
Options
Downloads
Patches
Plain Diff
adjust fallback to account for posting_json exception
parent
5b65514a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/avatar.ts
+18
-9
18 additions, 9 deletions
src/avatar.ts
with
18 additions
and
9 deletions
src/avatar.ts
+
18
−
9
View file @
fa808bf8
...
@@ -25,9 +25,6 @@ export async function avatarHandler(ctx: KoaContext) {
...
@@ -25,9 +25,6 @@ export async function avatarHandler(ctx: KoaContext) {
interface
IExtendedAccount
extends
Account
{
interface
IExtendedAccount
extends
Account
{
posting_json_metadata
?:
string
;
posting_json_metadata
?:
string
;
profile
?:
{
version
:
number
};
}
}
const
[
account
]:
IExtendedAccount
[]
=
await
rpcClient
.
database
.
getAccounts
([
username
])
const
[
account
]:
IExtendedAccount
[]
=
await
rpcClient
.
database
.
getAccounts
([
username
])
...
@@ -35,14 +32,26 @@ export async function avatarHandler(ctx: KoaContext) {
...
@@ -35,14 +32,26 @@ export async function avatarHandler(ctx: KoaContext) {
APIError
.
assert
(
account
,
APIError
.
Code
.
NoSuchAccount
)
APIError
.
assert
(
account
,
APIError
.
Code
.
NoSuchAccount
)
let
metadata
;
let
metadata
;
try
{
metadata
=
account
.
posting_json_metadata
?
JSON
.
parse
(
account
.
posting_json_metadata
)
:
JSON
.
parse
(
account
.
json_metadata
)
// read from `posting_json_metadata` if version flag is set
if
(
metadata
&&
metadata
.
profile
&&
metadata
.
profile
.
version
!==
2
)
{
if
(
account
.
posting_json_metadata
)
{
try
{
metadata
=
JSON
.
parse
(
account
.
posting_json_metadata
)
if
(
!
metadata
.
profile
||
!
metadata
.
profile
.
version
)
metadata
=
{}
}
catch
(
error
)
{
ctx
.
log
.
debug
(
error
,
'
unable to parse json_metadata for %s
'
,
account
.
name
)
metadata
=
{}
}
}
// otherwise, fall back to reading from `json_metadata`
if
(
!
metadata
)
{
try
{
metadata
=
JSON
.
parse
(
account
.
json_metadata
)
metadata
=
JSON
.
parse
(
account
.
json_metadata
)
}
catch
(
error
)
{
ctx
.
log
.
debug
(
error
,
'
unable to parse json_metadata for %s
'
,
account
.
name
)
metadata
=
{}
}
}
}
catch
(
error
)
{
ctx
.
log
.
debug
(
error
,
'
unable to parse json_metadata for %s
'
,
account
.
name
)
metadata
=
{}
}
}
let
avatarUrl
:
string
=
DefaultAvatar
let
avatarUrl
:
string
=
DefaultAvatar
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment