- removed ioutils in some spots

- fixed rate limit headers
- added poll data to post
- changed random os to windows for surf client
This commit is contained in:
2026-05-25 16:21:13 -05:00
parent 76c46f0a0d
commit d4a435b52f
2 changed files with 49 additions and 33 deletions
+29 -1
View File
@@ -434,6 +434,10 @@ type Comment struct {
CanGild bool `json:"can_gild"`
NSFW bool `json:"over_18"`
Distinguished string `json:"distinguished"`
Depth int `json:"depth"`
BodyHtml string `json:"body_html"`
Replies Replies `json:"replies"`
}
@@ -442,6 +446,11 @@ func (c *Comment) HasMore() bool {
return c.Replies.More != nil && len(c.Replies.More.Children) > 0
}
// Denotes whether the comment was written by a moderator
func (c *Comment) IsModerator() bool {
return c.Distinguished == "moderator"
}
// addCommentToReplies traverses the comment tree to find the one
// that the 2nd comment is replying to. It then adds it to its replies.
func (c *Comment) addCommentToReplies(comment *Comment) {
@@ -569,13 +578,32 @@ type Post struct {
PollData *PollData `json:"poll_data"`
}
type PollData struct {
type PollDataInner struct {
Timestamp int `json:"voting_end_timestamp"`
Options []PollOption `json:"options"`
IsPrediction bool `json:"is_prediction"`
TotalVoteCount int `json:"total_vote_count"`
}
type PollData struct {
PollDataInner
}
func (d *PollData) UnmarshalJSON(data []byte) error {
var junk bool
err := json.Unmarshal(data, &junk)
if err == nil {
return nil
}
inner := new(PollDataInner)
err = json.Unmarshal(data, inner)
if err != nil {
return err
}
d.PollDataInner = *inner
return nil
}
type PollOption struct {
Text string `json:"text"`
Id string `json:"id"`