Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
A
avatar-handler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
avatar-handler
Commits
fdf719a9
Commit
fdf719a9
authored
Nov 10, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix avatar loading
parent
01cf4d88
Pipeline
#6727
failed with stages
in 1 minute and 43 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
src/avatar.ts
src/avatar.ts
+8
-8
No files found.
src/avatar.ts
View file @
fdf719a9
...
...
@@ -6,9 +6,9 @@ import { CutData } from "./utility";
async
function
getRealUsername
(
originalUsername
:
string
)
{
try
{
const
{
user
:
{
name
,
username
}
}
=
(
await
axios
.
get
(
`https://ygobbs.com/users/
${
encodeURIComponent
(
originalUsername
)}
.json`
,
{
const
{
data
:
{
user
:
{
name
,
username
}
}
}
=
(
await
axios
.
get
(
`https://ygobbs.com/users/
${
encodeURIComponent
(
originalUsername
)}
.json`
,
{
responseType
:
"
json
"
}))
.
data
;
}));
return
[
name
,
username
];
}
catch
(
e
)
{
console
.
error
(
`User
${
originalUsername
}
not found:
${
e
.
toString
()}
`
);
...
...
@@ -16,12 +16,12 @@ async function getRealUsername(originalUsername: string) {
}
}
async
function
getAvatarURL
(
usernames
:
string
[])
{
for
(
le
t
username
of
usernames
)
{
async
function
getAvatarURL
(
usernames
:
string
[])
:
Promise
<
string
>
{
for
(
cons
t
username
of
usernames
)
{
try
{
const
{
data
:
avatar
}
=
(
await
axios
.
get
(
`https://api.moecube.com/accounts/users/
${
encodeURIComponent
(
username
)}
.json`
,
{
const
{
data
:
{
user
:
{
avatar
}
}
}
=
(
await
axios
.
get
(
`https://api.moecube.com/accounts/users/
${
encodeURIComponent
(
username
)}
.json`
,
{
responseType
:
"
json
"
}))
.
data
;
}));
if
(
avatar
?.
match
(
/^http
(
s
)?
:
\/\/
/
))
{
return
avatar
;
}
...
...
@@ -33,8 +33,8 @@ async function getAvatarURL(usernames: string[]) {
}
async
function
getURLFromUsername
(
username
:
string
)
{
const
possibleNames
=
await
getRealUsername
(
username
);
return
await
getAvatarURL
(
possibleNames
);
//
const possibleNames = await getRealUsername(username);
return
await
getAvatarURL
(
[
username
]
);
}
interface
QueryResult
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment