mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
Fix: user page doesn't work because of bad JSON parsing
This commit is contained in:
+2
-2
@@ -383,7 +383,7 @@ func (p *PixivClient) GetUserInformation(id string, page int) (*models.User, err
|
||||
|
||||
var body struct {
|
||||
*models.User
|
||||
Background map[string]string `json:"background"`
|
||||
Background map[string]interface{} `json:"background"`
|
||||
}
|
||||
|
||||
// Basic user information
|
||||
@@ -400,7 +400,7 @@ func (p *PixivClient) GetUserInformation(id string, page int) (*models.User, err
|
||||
|
||||
// Background image
|
||||
if body.Background != nil {
|
||||
user.BackgroundImage = body.Background["url"]
|
||||
user.BackgroundImage = body.Background["url"].(string)
|
||||
}
|
||||
|
||||
// Artworks count
|
||||
|
||||
+8
-1
@@ -81,7 +81,14 @@ func user_page(c *gin.Context) {
|
||||
}
|
||||
|
||||
pageInt, _ := strconv.Atoi(page)
|
||||
user, _ := PC.GetUserInformation(id, pageInt)
|
||||
user, err := PC.GetUserInformation(id, pageInt)
|
||||
if err != nil {
|
||||
c.HTML(http.StatusInternalServerError, "error.html", gin.H{
|
||||
"Title": "An error occured",
|
||||
"Error": err,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
worksCount, _ := PC.GetUserArtworksCount(id)
|
||||
pageLimit := math.Ceil(float64(worksCount)/30.0) + 1.0
|
||||
|
||||
Reference in New Issue
Block a user