summaryrefslogtreecommitdiff
path: root/internal/ap/extract.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ap/extract.go')
-rw-r--r--internal/ap/extract.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/internal/ap/extract.go b/internal/ap/extract.go
index b412f251d..424f77409 100644
--- a/internal/ap/extract.go
+++ b/internal/ap/extract.go
@@ -1125,26 +1125,31 @@ func ExtractPoll(poll Pollable) (*gtsmodel.Poll, error) {
// Check if counts have been hidden from us.
hideCounts := len(options) != len(votes)
- if hideCounts {
- // Zero out all votes.
- for i := range votes {
- votes[i] = 0
- }
- }
-
- // Extract the poll end time.
- endTime := GetEndTime(poll)
- if endTime.IsZero() {
- return nil, errors.New("no poll end time specified")
+ if hideCounts {
+ // Simply provide zeroed slice.
+ votes = make([]int, len(options))
}
- // Extract the poll closed time.
+ // Extract the poll closed time,
+ // it's okay for this to be zero.
closedSlice := GetClosed(poll)
if len(closedSlice) == 1 {
closed = closedSlice[0]
}
+ // Extract the poll end time, again
+ // this isn't necessarily set as some
+ // servers support "endless" polls.
+ endTime := GetEndTime(poll)
+
+ if endTime.IsZero() && !closed.IsZero() {
+ // If no endTime is provided, but the
+ // poll is marked as closed, infer the
+ // endTime from the closed time.
+ endTime = closed
+ }
+
// Extract the number of voters.
voters := GetVotersCount(poll)