- 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:
+29
-1
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user