From deaea100c37698893e97cf9cab159a3d220ac3cd Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Sat, 11 Nov 2023 10:15:04 +0000 Subject: [bugfix] support endless polls, and misskey's' method of inferring expiry in closed polls (#2349) --- internal/ap/extract.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'internal/ap/extract.go') 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) -- cgit v1.2.3