mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-12-14 12:15:22 +00:00
added covers to user comment page
This commit is contained in:
28
api/user.go
28
api/user.go
@@ -111,7 +111,7 @@ func (client *Client) FetchUserComments(username string, page string) ([]Comment
|
||||
|
||||
q := req.URL.Query()
|
||||
q.Add("client_id", client.ClientID)
|
||||
q.Add("filter[account]", "eq:wouldaponybyanyothernamebeasoffencive")
|
||||
q.Add("filter[account]", "eq:"+username)
|
||||
q.Add("include", "account,post")
|
||||
q.Add("sort", "new")
|
||||
|
||||
@@ -150,20 +150,30 @@ func (client *Client) FetchUserComments(username string, page string) ([]Comment
|
||||
}
|
||||
|
||||
func parseSubmission(value gjson.Result) Submission {
|
||||
coverData := value.Get("images.#(id==\"" + value.Get("cover").String() + "\")")
|
||||
cover := 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", ""),
|
||||
}
|
||||
if coverData.Exists() {
|
||||
var cover Media
|
||||
c := value.Get("cover")
|
||||
coverData := value.Get("images.#(id==\"" + c.String() + "\")")
|
||||
switch {
|
||||
case c.Type == gjson.String && coverData.Exists():
|
||||
cover = 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", ""),
|
||||
}
|
||||
// This case is when fetching comments
|
||||
case c.Type != gjson.Null:
|
||||
cover = Media{
|
||||
Id: c.Get("id").String(),
|
||||
Url: c.Get("url").String(),
|
||||
}
|
||||
default:
|
||||
cover = 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()
|
||||
|
||||
Reference in New Issue
Block a user