diff options
author | 2023-11-11 10:15:04 +0000 | |
---|---|---|
committer | 2023-11-11 10:15:04 +0000 | |
commit | deaea100c37698893e97cf9cab159a3d220ac3cd (patch) | |
tree | f48abc96964652d1701d91c88a00174c8f1b0196 /internal/ap | |
parent | [feature] Media attachment placeholders (#2331) (diff) | |
download | gotosocial-deaea100c37698893e97cf9cab159a3d220ac3cd.tar.xz |
[bugfix] support endless polls, and misskey's' method of inferring expiry in closed polls (#2349)
Diffstat (limited to 'internal/ap')
-rw-r--r-- | internal/ap/extract.go | 29 |
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) |