added user comments

This commit is contained in:
orangix
2023-08-15 17:38:44 +02:00
parent 493a17385a
commit 3faef9aeb9
6 changed files with 232 additions and 45 deletions

View File

@@ -9,21 +9,21 @@ import (
"codeberg.org/rimgo/rimgo/utils"
"github.com/dustin/go-humanize"
"github.com/microcosm-cc/bluemonday"
"github.com/patrickmn/go-cache"
"github.com/tidwall/gjson"
"gitlab.com/golang-commonmark/linkify"
)
type Comment struct {
Comments []Comment
User User
User User
Post Submission
Id string
Comment string
Upvotes int64
Downvotes int64
Platform string
CreatedAt string
RelTime string
RelTime string
UpdatedAt string
DeletedAt string
}
@@ -55,7 +55,6 @@ func (client *Client) FetchComments(galleryID string) ([]Comment, error) {
)
wg.Wait()
client.Cache.Set(galleryID + "-comments", comments, cache.DefaultExpiration)
return comments, nil
}
@@ -130,13 +129,14 @@ func parseComment(data gjson.Result) Comment {
Username: data.Get("account.username").String(),
Avatar: userAvatar,
},
Post: parseSubmission(data.Get("post")),
Id: data.Get("id").String(),
Comment: comment,
Upvotes: data.Get("upvote_count").Int(),
Downvotes: data.Get("downvote_count").Int(),
Platform: data.Get("platform").String(),
CreatedAt: createdAt,
RelTime: humanize.Time(createdTime),
RelTime: humanize.Time(createdTime),
UpdatedAt: updatedAt,
DeletedAt: deletedAt,
}