Fix single user posts (#10)
This commit is contained in:
parent
379a1f3b81
commit
a029f0d197
43
api/user.go
43
api/user.go
|
@ -61,24 +61,37 @@ func FetchSubmissions(username string, sort string, page string) ([]types.Submis
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
cover := value.Get("images.#(id==\"" + value.Get("cover").String() + "\")")
|
coverData := value.Get("images.#(id==\"" + value.Get("cover").String() + "\")")
|
||||||
|
cover := types.Media{}
|
||||||
|
if coverData.Exists() {
|
||||||
|
cover = types.Media{
|
||||||
|
Id: coverData.Get("id").String(),
|
||||||
|
Description: coverData.Get("description").String(),
|
||||||
|
Type: strings.Split(coverData.Get("type").String(), "/")[0],
|
||||||
|
Url: strings.ReplaceAll(coverData.Get("link").String(), "https://i.imgur.com", ""),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cover = types.Media{
|
||||||
|
Id: value.Get("id").String(),
|
||||||
|
Description: value.Get("description").String(),
|
||||||
|
Type: strings.Split(value.Get("type").String(), "/")[0],
|
||||||
|
Url: strings.ReplaceAll(value.Get("link").String(), "https://i.imgur.com", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
id := value.Get("id").String()
|
||||||
|
|
||||||
submissions = append(submissions, types.Submission{
|
submissions = append(submissions, types.Submission{
|
||||||
Id: value.Get("id").String(),
|
Id: id,
|
||||||
Link: strings.ReplaceAll(value.Get("link").String(), "https://imgur.com", ""),
|
Link: "/a/" + id,
|
||||||
Title: value.Get("title").String(),
|
Title: value.Get("title").String(),
|
||||||
Cover: types.Media{
|
Cover: cover,
|
||||||
Id: cover.Get("id").String(),
|
Points: value.Get("points").Int(),
|
||||||
Description: cover.Get("description").String(),
|
Upvotes: value.Get("ups").Int(),
|
||||||
Type: strings.Split(cover.Get("type").String(), "/")[0],
|
Downvotes: value.Get("downs").Int(),
|
||||||
Url: strings.ReplaceAll(cover.Get("link").String(), "https://i.imgur.com", ""),
|
Comments: value.Get("comment_count").Int(),
|
||||||
},
|
Views: value.Get("views").Int(),
|
||||||
Points: cover.Get("points").Int(),
|
IsAlbum: value.Get("is_album").Bool(),
|
||||||
Upvotes: cover.Get("ups").Int(),
|
|
||||||
Downvotes: cover.Get("downs").Int(),
|
|
||||||
Comments: cover.Get("comment_count").Int(),
|
|
||||||
Views: cover.Get("views").Int(),
|
|
||||||
IsAlbum: cover.Get("is_album").Bool(),
|
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue