From ac481925622df9bf8024d1b5726282d0214fd22b Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Tue, 12 Dec 2023 13:47:07 +0000 Subject: [bugfix] poll vote count fixes (#2444) * don't drop all vote counts if hideCounts is set, refactors poll option extraction slightly * omit voters_count when not set * make voters_count a ptr to ensure it is omit unless definitely needed * handle case of expires_at, voters_count and option.votes_count being nilable * faster isNil check * remove omitempty tags since mastodon API marks things as nullable but still sets them in outgoing json --- internal/api/model/poll.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'internal/api/model') diff --git a/internal/api/model/poll.go b/internal/api/model/poll.go index 3eb801998..5603ff222 100644 --- a/internal/api/model/poll.go +++ b/internal/api/model/poll.go @@ -28,7 +28,7 @@ type Poll struct { ID string `json:"id"` // When the poll ends. (ISO 8601 Datetime). - ExpiresAt string `json:"expires_at"` + ExpiresAt *string `json:"expires_at"` // Is the poll currently expired? Expired bool `json:"expired"` @@ -40,7 +40,7 @@ type Poll struct { VotesCount int `json:"votes_count"` // How many unique accounts have voted on a multiple-choice poll. - VotersCount int `json:"voters_count"` + VotersCount *int `json:"voters_count"` // When called with a user token, has the authorized user voted? // @@ -68,7 +68,7 @@ type PollOption struct { Title string `json:"title"` // The number of received votes for this option. - VotesCount int `json:"votes_count"` + VotesCount *int `json:"votes_count"` } // PollRequest models a request to create a poll. -- cgit v1.2.3